Description
This recipe is useful when you have a large suite of unit tests and you don't want to be burdened with maintaining Test List (*.vsmdi) files.
This works out of the box on a TFS 2008 Team Build.
However, there is a problem if you want to run the script as a Desktop Build (
http://msdn2.microsoft.com/en-us/library/ms181292.aspx). The bug in Team Build 2008
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=324863.
Usage
Add to TFSBuild.proj
Script
<!-- TFS Build 2008.
This snippet finds assemblies matching the pattern *.Tests.dll in the
output directory of the build.
It then creates the TestContainer and LocalTestContainer items so that
the <TestToolsTask> is able to run MSTest.exe.
-->
<Target Name="BeforeTestConfiguration">
<Message Text="Using unit tests from: $(BinariesRoot)\$(Configuration)\*.Tests.dll"
Condition=" '$(IsDesktopBuild)'=='true' " />
<CreateItem Include="$(BinariesRoot)\$(Configuration)\*.Tests.dll">
<Output TaskParameter="Include" ItemName="LocalTestContainer"/>
<Output TaskParameter="Include" ItemName="TestContainer"/>
</CreateItem>
<Message Text="LocalTestContainer: @(LocalTestContainer)"
Condition=" '$(IsDesktopBuild)'=='true' " />
</Target>
Notes
- Currently it matches all *.Tests.dll outputs in the \Binaries\Release\ folder. If your test assemblies are named differently, you will need to update this.
- It might be useful to store this workaround in a TestContainerWorkaround.targets file, then add an <Import Project="TestContainerWorkaround.targets" />.