开发者

How do I get Visual Studio to place the unit tests where I want them?

In both VSTS 2008 and VS 2010 RC1 when I create a Unit Test (mstest), I am not asked where I would like the project to be placed. It will always turn up at the Solution level. I would like to place the test project inside the folder of the class(es) that are being tested.

I have tried unloading the unit test project and adding it to the class library, but that breaks the coupling with the class.

I am using Visual Studio 2010 Ultimate RC1 with ReSharper 5.0 and Visual Stuido 2008 with RS 4.5.

TIA, Jim

Amended: I was not at all clear about placing the unit tests. I have a Solution with several Solution Folders. One of these is a common library. I would like to add unit tests for some classes in the library. VS will place the TestProject at the base Solution level. I would prefer

mySolution

mySolution\SolutionFolder

mySolution\SolutionFolder\ClassLibrary

mySolution\SolutionFolder\ClassLibrary\Class1.cs

mySolution\SolutionFolder\ClassLibrary\Class2.cs

mySolution\SolutionFolder\UnitTestForClass1

mySolution\SolutionFolder\UnitTestFOrClass2

Instead, VS will do:

mySolution

mySolution\SolutionFolder

mySolution\SolutionFolder\ClassLibrary

mySolution\SolutionFolder\ClassLibrary\Class1.cs

mySolution\Solution开发者_运维百科Folder\ClassLibrary\Class2.cs

mySolution\UnitTestForClass1

mySolution\UnitTestFOrClass2

I hope this is clearer. Thank you. I do apologize for all the miss-edits I have posted.


The normal practice is to segregate byb source/source and source/test at the highest level.

In other words, suppose you have a "solution" with 3 projects, each of which builds a distinct assembly. You might have a source tree like this:

soln\sourcesrc\proj1
soln\sourcesrc\proj2
soln\sourcesrc\proj3

The test code would normally be like this:

soln\testsrc\proj1
soln\testsrc\proj2
soln\testsrc\proj3

This is independent of Visual Studio or mstest. This is just how I have seen it done, pretty much everywhere.


Projects don't go inside of other projects with Visual Studio. Is there any other project type you've seen go inside of another project?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜