Let's assume a pared down version of our previous example, we have
- Example.Continuous, our build project
- Example.UnitTests, a project containing tests
- NUnit in a Resources folder
Example.Continuous declares build target AdditionalTasks, and the following property and item groups.
What we want to do is leverage NUnit's result switch and specify output files for each test run. To do so, we will introduce both a new property for the results path and additional item paths to specify output files. We are being very explicit here to better support spaces in folder paths (eg default project folders are located under "Visual Studio 2012" folder)."$(MSBuildProjectDirectory)\..\Resources\NUnit-2.6.0.12051\nunit-console.exe" $(MSBuildProjectDirectory)\..\Example.UnitTests\$(OutputPath)
This is our new project file after our modifications!
"$(MSBuildProjectDirectory)\..\Resources\NUnit-2.6.0.12051\nunit-console.exe" $(MSBuildProjectDirectory)\..\TestResults\NUnit\ $(MSBuildProjectDirectory)\..\Example.UnitTests\$(OutputPath) "$(TestResultsFolder)Example.UnitTests.dll.xml"