I have a number of C# integration tests written using the Given/When/Then style popularized by cucumber. I'm using a framework which basically works the same as NBehave.
A recurring issue I'm facing is the issue of setup and wiring up all the application state necessary for the integration test. Most of my tests look something like this:
Given an empty system And a new NetworkServer And a new ServerDatabase And a new Eventlogger And a new Networkconnection And a new LoggingClient When the client logs a new event Then it should appear in the server database
As you can see the action and assertion are single lines, but I have 6 lines of 'wiring'. Almost every test I have repeats these 6 lines.
This seems like a code smell to me, but I'm unsure as to how to handle this. I could refactor the 6 lines into a single one (Given "a valid system..."
or somesuch) but that seems like it goes too far and I'd be hiding too much information.
I'd appreciate any thoughts from others with more experience in this area. Thanks a lot.