MSBuild - attempt to run xUnit tests (.net)

I am trying to create a C # project that will run xUnit tests when building, so I can use them in continuous integration. I have a regular project, a test class library project using xUnit and my test run project. From everything I've read, it seems that I should get this working by doing this in a test runner project:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Test"
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  [auto-created project stuff]
  <UsingTask AssemblyFile="xunit.runner.msbuild.dll"
      TaskName="Xunit.Runner.MSBuild.xunit" />
  <Target Name="Test">
    <xunit Assembly="$(MSBuildProjectDirectory)\..\OnePageOneDb.Tests\bin\Debug\OnePageOneDb.Tests.dll" />
  </Target>
</Project>

When I create my solution after the change (usually editing the .csproj file), I get the following:

The task "Xunit.Runner.MSBuild.xunit" cannot be loaded from the assembly C: \ Users [MyUserName] \ Code \ OnePageOneDb \ OnePageOneDb.TestRunner \ xunit.runner.msbuild.dll. Failed to load file or assembly 'File: /// C: \ Users [MyUserName] \ Code \ OnePageOneDb \ OnePageOneDb.TestRunner \ xunit.runner.msbuild.dll' or one of its dependencies. The system cannot find the specified file. Confirm that the declaration is true that the assembly and all its dependencies are available, and that the task contains an open class that implements Microsoft.Build.Framework.ITask.

Even if I add xunit.runner.msbuild.dll and xunit.runner.utility.dll to the project in the place to which it refers, I get this message. But if I create again without changes, I sequentially get the following:

"xunit" . : 1.) . 2.) "" Microsoft.Build.Framework.ITask . 3.) *.tasks "C:\Windows\Microsoft.NET\Framework\v4.0.30319" .

:

  • xunit.runner.msbuild.dll Xunit.Runner.MSBuild.xunit ( xunit ).
  • Task, ITask.
  • , , UseTask, , .

( , , xunit.runner.msbuild.dll .NET 2.0, VS 2010, .NET 2.0, . )

- ?

+5
3

xunit.runner.msbuild.dll. , , xunit , . dll.

<UsingTask AssemblyFile="$(MSBuildProjectDirectory)\..\..\lib\xunit\xunit.runner.msbuild.dll"
           TaskName="Xunit.Runner.MSBuild.xunit" />

MSBuildProjectDirectory - " , ".

EDIT:

Xunit.Runner.MSBuild.xunit

<Target Name="Test">
    <Xunit.Runner.MSBuild.xunit Assembly="$(MSBuildProjectDirectory)\..\OnePageOneDb.Tests\bin\Debug\OnePageOneDb.Tests.dll" />
</Target>
+2

, Pex Moles. .

0

By default, "release" configuration triggers are created that run xunit tests. If you are trying to disable xunit tests in tfsbuild pass, run the following build option. This can be useful in new cross-platform builds, where running individual tests is a separate step.

/p:RunXunitTests=false
0
source

All Articles