Please see the DOS command below:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe WindowsFormsApplication1.csproj /t:Test
The .csproj file looks like this:
<PropertyGroup>
<NUnit3-ToolPath>C:\Development\C#\UnitTests\UnitTests\packages\NUnit.ConsoleRunner.3.6.1\tools</NUnit3-ToolPath>
</PropertyGroup>
<Target Name="Test">
<NUnit3 ToolPath="$(NUnit3-ToolPath)" Assemblies="C:\Development\C#\UnitTests\WindowsFormsApplication1\bin\Debug\UnitTests.dll" OutputXmlFile="test-results.xml" />
</Target>
If I exclude: /t:Test
from the DOS command then the build succeeds even if the unit tests fail. How do I ensure the unit tests are run when this command is run:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe WindowsFormsApplication1.csproj
The answer was just to add an AfterTargets attribute as follows:
<Target Name="Test" **AfterTargets="Build">**
<NUnit3 ToolPath="$(NUnit3-ToolPath)" Assemblies="C:\Development\C#\UnitTests\WindowsFormsApplication1\bin\Debug\UnitTests.dll" OutputXmlFile="test-results.xml" /> </Target>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.