David Edgar, whose play Testing the Echo comes to his home town tonight after a national tour, reflects on the way that fact has followed fiction since he finished writing it last year.

----

As writers about royal romances found in the late 1990s, accidental topicality can be a danger as well as a bonus for the author.

At least one play had to be substantially rewritten - and another failed at the box office - immediately following the death of Princess Diana.

Along with a large number of films, the Broadway musical Assassins was shelved after 9/11, and, last year, the BBC postponed the broadcast of a Hanif Kureishi short story about jihadist hostage-taking while Alan Johnson remained incarcerated in Gaza. And productions of Henry V raised unintentional laughs during the BSE crisis when the Duke of Orleans remarked that "these English are shrewdly out of beef".

When I proposed writing a play about British identity for the touring company Out of Joint, I guessed/hoped that the play's topic would hit the headlines during our run. Testing the Echo is topped and tailed by one of the ceremonies that have proved so unexpectedly popular with new British citizens, and, in between, tells several interlocking tales of people who are mugging up the information you have to know to become one (from the number of members of the Welsh assembly to the distance between John O'Groats and Land's End).

These stories range from a Muslim drug addict going cold turkey via a football fanatic Korean car mechanic in New Malden and a Ukrainian woman trapped in an unhappy marriage in Balsall Heath to an entire class of English language students in a North London college.

As the play was researched, written and rehearsed last summer and autumn, we worked out that the Government's new citizenship proposals (establishing a points system and adding good behaviour hurdles) would probably come out during our projected tour. We also thought that Lord Goldsmith's report on British identity (the one that proposed citizenship ceremonies for 18-year-olds) would - with luck - hit the streets while we were still treading the boards.

We had no idea how spookily topical we would turn out to be, on matters great and small.

In the play, a civil servant is backed into defining Britishness as "the need and capacity to find a dentist": back in January, a day before we opened in Salisbury, the Citizens' Advice Bureau announced that one in 10 British people couldn't get dental treatment on the NHS. Following the Archbishop of Canterbury's speech about sharia law, Edinburgh audiences couldn't believe we hadn't added in our scene on that topic (starting with the line "They don't mean cutting people's hands off") to the play that morning.

One of the subjects of the play is the difficulty of agreeing a shared narrative of British history (hence the citizenship test remaining resolutely contemporary, unlike that of every other country). While we were in Liverpool, the Royal United Services Institute issued a report complaining that there is no shared narrative of British history.

The week after that, we were in Warwick and the Prime Minister was announcing his plans to make it harder to do what most of the characters in the play want to do (though we hoped this wasn't our fault).

As we began our week in Guildford, David Cameron made a speech attacking multiculturalism, with arguments echoed by one of the main characters in the play, and two days after we closed there, Margaret Hodge criticised the proms for lacking diversity. (In its closing moments, the play quotes a line from Jerusalem). And two weeks ago, as we came to the end of our run at the Tricycle Theatre in London, former Muslim radicals set up a foundation to try and stop disaffected young Muslim men turning to extremism. One of the plots of Testing the Echo concerns a disaffected young Muslim man trying to another man not to turn to extremism.

Finally, last week we became part of our own story, as a performance of the play at the Tricycle Theatre was followed by an actual citizenship ceremony in the theatre, life following art with a vengeance.

We have of course been lucky in two senses: in addition to the topical things that have happened, it is possible to imagine things that haven't happened which would have required us either to rewrite the text or even suspend performances. But, as the play reaches the the climax of its tour at the Birmingham Rep (usually my plays start here, so this is a refreshing variation), our shadowing of the day's headlines remind us of the uniquely present-tense nature of the theatre.

Sometimes this is a literal matter: last summer, playwright Mark Ravenhill entertained Edinburgh Festival audiences with a series of 16 20-minute plays written the day before their premiere performance.

In our case, the topicality of a play first conceived over a year ago resulted from a combination of foreknowledge and luck, and few theatres (sadly) can emulate Radio Four's current From Fact to Fiction season of plays conceived, written, recorded and broadcast in a week.

But the live presence of actors and audience in the same room allows the accidentally or deliberately topical to become tangible, as the relevance of the play to a day's big story hums round the auditorium.

The title Testing the Echo refers to a jokey list of unhelpful pieces of advice to foreigners ("During your visit, you should not fail to test the famous echo in the reading room of the British Library"). But, in this case, we've been lucky enough to hear echoes of the morning's news as well.

* Out of Joint's production of David Edgar's Testing the Echo runs at the Birmingham Repertory Theatre from Wednesday May 7 to Saturday, May 10. Performances at 7.00pm (Wednesday), and 7.30pm thereafter, with a matinee on Saturday at 2.30pm.