Tuesday, January 8, 2008

Unit testing discussions and nested code files

We had some discussions about my Unit testing pattern-article in one of the forums over at Channel 9. I noticed that a lot of people misread my intentions of the pattern a bit and thought that the advantage of using it is that it enables you to test non public methods, this is however just a side effect (desirable or not) of using the pattern. Therefore I've updated the article to better reflect my intentions.

Nested files

I also added a neat little trick that shows how to make code files depend upon other code files in Visual Studio enabling them to collapse nicely under the file they depend upon.

Nested or dependent files in Visual Studio.

To do this, open the project-file in an editor and locate the Compile-element representing the file you want to be nested under another file. Insert a "DependentUpon" XML element under this element and use the file name of the file it depends upon as the value:

<!-- Change this: -->
<Compile Include="Foo.Tests.cs" />
<!-- Into this: -->
<Compile Include="Foo.Tests.cs">

No comments:

Post a Comment