Dear ladies and sirs.
I have recently encountered some inconsistencies in running unit tests inside VS2008 vs running the same unit tests with mstest on the command line.
My scenario is a bit advanced, so I have probably hit some corners. I have many data driven unit tests running against the same DataSource. I also like experimenting with PostSharp. So, I have written a PostSharp aspect - TestDataSource
- which I apply to a unit test type, not the unit test methods. When the type is built, this aspect instructs PostSharp to attach the DataSource
attribute to each and every unit test method in the type.
Examining the built assembly in Reflector shows that each test method is indeed attributed with the correct DataSource
attribute. Running the tests with mstest on the command line behaves as expected - each test is run against the specified data source.
However, running exactly the same unit tests in VS2008 fails to find the data source. It is as though VS2008 ignores the built assembly and looks at the source code, which, of course, does not appear to be a data driven test, because the DataSource
attribute is injected during the build.
There is no problem with deployed items. Attaching the DataSource
manually to the tests makes VS2008 run them happily.
Any ideas?
Thanks.