If you've got here because you wish to add
Unit Test execution to your
existing TFS server build to execute
ALL TESTS in your solution ("Why on earth would you want to do that?" you ask), and you've scoured the internet and become
incredibly frustrated that all you can find are people who tell you how "easy" it is to do in TFS without actually telling you
how to do it, this may help...
The long winded "help yourself" solution
Create a new build type (Team Explorer > ProjectName > Builds > (right click) > "New Build Definition" in VSTS 2008) as described above, and look for the secret hidden test options (hint: In the project File tab, Click the Create... button, select your project(s), then go to the Options tab. Aha! Test options! obvious!). Set them up to use your vsmdi (or better, *Test*.dll so that the tests will just automatically pick up any new dlls you write with the word "Test" in their name) and then look at the Test section of the TFSBuild.proj that it generates to find the magic line or two of XML that you need to add to your existing build script. Add it in and then you can just delete the new Build Type.
The short "here's the magic secret handshake" solution
You will no doubt be amazed to hear that the solution can be as simple as this:
- In your main propertyGroup, make sure that you have set:
<RunTest>true</Runtest>
- In the first test <ItemGroup> where there are examples of how to add specific tests using <TestContainer> commands, add the following command:
<TestContainer Include="$(OutDir)\%2aTest%2a.dll" />
(The %2a represents a wildcard asterisk, i.e. "$(OutDir)\*Test*.dll" but it is encoded in this way to stop it being expanded to early in the build process).
This will set up your build to run unit tests from all the dlls in your build that include Test in their filename.
HTH