I have a solution with a few nunit test assemblies and several more in the works.
Right now, I'm running my nunit command in my msbuild file like so:
<Exec Command="nunit-console src\Assembly1.Tests\bin\Debug\Assembly1.Tests.Tests.dll src\Assembly2.Tests\bin\Debug\Assembly2.Tests.Tests.dll src\Assembly3.Tests\bin\Debug\Assembly3.Tests.Tests.dll src\Assembly4.Tests\bin\Debug\Assembly4.Tests.Tests.dll" />
Clearly this is unreadable and sucks. So the question is how do I improve this? Specifically:
- Is there some way I can put the test assemblies in a list and get output equivalent to
foreach(var assembly in testAssemblies) string.Format("src\\{0}\\bin\\debug\\{1}", assembly)
- Should I be running all of my tests in a single nunit-console开发者_StackOverflow中文版 command? I'm guessing yes because I want it all in a single output file, and a single command which returns 0 or non-zero (thus failing the build if non-zero).
Think the highest ranked answer on this question has what you need.
Specifically the target filter that allows you to specify all assemblies but also specify name filtering if there's some you don't want to run:
<Target Name="GetTestAssemblies">
<CreateItem
Include="$(WorkingDir)\unittest\**\bin\$(Configuration)\**\*Test*.dll"
AdditionalMetadata="TestContainerPrefix=/testcontainer:">
<Output
TaskParameter="Include"
ItemName="TestAssemblies"/>
</CreateItem>
精彩评论