views:

121

answers:

2

I know there is no right or wrong answer to this but it would be VERY helpful to see how others have structured their test projects? Especially for multi assembly solutions and managing different test phases, unit, integration, system?

And ontop of it all it would be helpful to see what structure fits nicely for running test builds on a Continuous Integration Server (TeamCity)?

Initially I am starting out with:

Test (Namespace)
--Unit (Folder)
----ClassATests 
----ClassBTests
--Integration (Folder)
----ClassA+BTests 
----DBTests
+1  A: 

I keep my unit tests and integration tests in separate assemblies (x.Tests.dll, y.IntegrationTests.dll) in order to be able to easily find test assemblies to run during the build process. I can then just locate *.Tests.dll and run them as part of a daily build. Integration tests are run manually in specific environments, but can still be run from a simple build script.

Apart from that, TestClass-per-Class is pretty much the rule I've followed with the exception being small helper classes that are all tested from a single HelperTests fixture.

Simon Steele
Thank you. Very helpful indeed.
+1  A: 

I've been thinking about this very thing at work today. I've inherited a test project that has been maintained and updated by multiple people in the past, and as such currently contains a rather confusing hierarchy.

In an attempt to simplify matters, I have started out using the following structure:

Tests (Namespace)
-- Infrastructure (Folder)
---- general utility classes (common to all tests)
---- any other config
-- ClassATests (Folder)
---- ClassATestBase (base class for setup of common mock objects etc.)
---- ClassATestMethods (helper methods for the ClassATests)
---- ClassATests (main test class)
-- ClassBTests (Folder)
etc.

I've found this approach to useful so far, as it means most of the code that will run during any given test can be found in the same folder. It also aims to avoid the scenario of one huge TestMethods class.

This may not be the most elegant of solutions (sorry, no pun intended!), but its working for me at present. Any and all suggestions are most welcome though!

BenA