Yossi Dahan [BizTalk]


Friday, October 08, 2010

Visual Studio 2008, unit testing and partial classes

Been working on some code for which I have a decent amount of unit tests (around 350 individual tests), and was quite proud of myself.

The unit tests are dividing to different test classes, each groups related tests together.

At some point I realised one of these test classes is getting quite large, and for ease of maintenance I decided to split it into several files, using the partial class approach, everything seemed to work ok – I kept the TestClass attribute on one file, and made all the other files partial, everything compiled and unit tests ran just fine.

Today I added a new unit test to one of these files, and for good 10 minutes I couldn’t realise why it does not appear in the test view list, until Oleg pointed out other tests in this file do not appear as well.

I’ve renamed the class, removed the partial keyword and added the TestClass attribute and the tests appeared (and ran) just fine.

Looks like a bug in VS, which does not consider test methods in partial class files, weird.

On the negative side – I had a bunch of test I never actually ran, and did not notice.

On the positive side – I now have 15 more tests running on my code!


Post a Comment

<< Home