Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to collect NUnit reports with MSBuild?
    text
    copied!<p>I've recently introduced NUnit to a Visual Studio C# project. The project folder structure looks like</p> <pre><code>- project root -- applications (rich client interface, web interface, small tools) -- components (business logic) -- vendor (3rd party components) -- tests (Nunit tests) </code></pre> <p>For each Visual Studio project "MyProject" under applications or components there is a corresponding project under tests named "MyProject.Test". When I introduced the NUnit test, I put the following in each .Test.csproj file:</p> <pre><code>&lt;Target Name="AfterBuild"&gt; &lt;CreateItem Include="$(TargetPath)"&gt; &lt;Output TaskParameter="Include" ItemName="MyProjectTests" /&gt; &lt;/CreateItem&gt; &lt;!-- Create folder for test results --&gt; &lt;MakeDir Directories="$(OutDir)\TestResults" /&gt; &lt;!-- Run tests--&gt; &lt;NUnit Assemblies="@(MyProjectTests)" ToolPath="..\vendor\NUnit\bin" OutputXmlFile=".\TestResults\MyProject.Test.Results.xml" WorkingDirectory="$(OutDir)" /&gt; &lt;!-- Create HTML report --&gt; &lt;Xslt Inputs="$(OutDir)\TestResults\MyProject.Test.Results.xml" Xsl="$(MSBuildCommunityTasksPath)\NUnitReport.xsl" RootTag="Root" Output="$(OutDir)\TestResults\MyProject.Test.Results.html" /&gt; &lt;/Target&gt; </code></pre> <p>This works fine, both when building solutions from within Visual Studio as well as on a build server with the MSBuild CLI.</p> <p>The remaining inconvenience of that approach is that it leaves me with the test reports in a TestResults folder in each test projects output folder, but with nothing in my solution's main output folder. So, my question is:</p> <p>What is the preferred way of collecting the resulting NUnit html reports in the solution's/startup project's output folder? What MSBuild instructions should I place in which .csproj file? I'm just getting started with MSBuild and I can't figure out the best practice...</p> <p>It has to work both in Visual Studio and with the MSBuild CLI, but that shouldn't be a problem, I guess.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload