Running xunit.net Tests in VSTS

I have a validation problem xunit.net

in VSTS

. When the build plan is executed, the step Test assemblies

generates the following log:

2017-03-21T12: 11: 39.3302859Z ## [section] Start: test builds
2017-03-21T12: 11: 39.3382932Z ===================== ================================================== ======================= ========================== ===========
2017-03-21T12: 11: 39.3382932Z Task: Visual Studio Test
2017-03-21T12: 11: 39.3382932Z Description: Run the tests with the Visual Studio
Tester 2017-03-21T12 : 11: 39.3382932Z Version: 1.0.84
2017-03-21T12: 11: 39.3382932Z Author: Microsoft Corporation
2017-03-21T12: 11: 39.3382932Z Help: More information
2017-03-21T12: 11: 39.3382932Z == ================================================== ==================================================== ===============================
2017-03-21T12: 11: 39.3493151Z Preparing the task execution handler.
2017-03-21T12: 11: 44.9245238Z Executing powershell script: D: \ a_tasks \ VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9 \ 1.0.84 \ VSTest.ps1
2017-03-21T12: 11: 46.6530959Z Test container: 'REGISTRY :: HKEY_CLASSES_ROOT \ CLSID {177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}'
2017-03-21T12: 11: 46.6530959Z
2017-03-21T12: 11: 46.6530959Z
2017-03-21T12: 11Z: 46.6810971 Not exist.
2017-03-21T12: 11: 46.6820975Z
2017-03-21T12: 11: 46.6820975Z
2017-03-21T12: 11: 46.8520939Z Working folder: D: \ a \ 1 \ s
2017-03-21T12: 11: 46.8520939Z Executing C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow \ vstest.console.exe "D: \ a \ 1 \ s \ Common.Tests \ bin \ Release \ MyClassLibrary.Tests.dll "/ Settings:" C: \ Users \ buildguest \ AppData \ Local \ Temp \ tmp89AE.tmp "/ EnableCodeCoverage / logger: trx / TestAdapterPath:" D: \ a \ 1 \ s "
2017-03-21T12: 11: 47.2730887Z Microsoft (R) Runtime Command Line Tool Version 14.0.25420.1
2017-03-21T12: 11: 47.2740881Z Copyright (c) Microsoft Corporation. All rights reserved.
2017-03-21T12: 11: 47.2740881Z
2017-03-21T12: 11: 47.7430814Z Starting test execution, please wait ...
2017-03-21T12: 12: 01.0768912Z Warning: [xUnit.net 00: 00: 01.1926376] Skip: MyClassLibrary.Tests (Could not find any of the following assemblies: xunit.execution.desktop.dll)
2017-03-21T12 : 12: 01.0768912Z
2017-03-21T12: 12: 01.1458970Z Warning: no test in D: \ a \ 1 \ s \ Common.Tests \ bin \ Release \ MyClassLibrary.Tests.dll. Please make sure the installed testers and executors, platform settings and platform versions are correct and try again.

The file packages.config

for this project is as follows:

<? xml version = "1.0" encoding = "utf-8"?>
<packages>
  ...
  <package id = "xunit" version = "2.2.0" targetFramework = "net45" />
  <package id = "xunit.abstractions" version = "2.0.1" targetFramework = "net45" />
  <package id = "xunit.assert" version = "2.2.0" targetFramework = "net45" />
  <package id = "xunit.core" version = "2.2.0" targetFramework = "net45" />
  <package id = "xunit.extensibility.core" version = "2.2.0" targetFramework = "net45" />
  <package id = "xunit.extensibility.execution" version = "2.2.0" targetFramework = "net45" />
  <package id = "xunit.runner.msbuild" version = "2.1.0" targetFramework = "net45" />
  <package id = "xunit.runner.visualstudio" version = "2.2.0" targetFramework = "net45" developmentDependency = "true" />
</packages>

The values ​​used during the build phase Test assemblies

:

Execution options

Test Build: **\*Tests.dll;-:**\obj\**


Code Coverage Included:true

Extended execution options

VSTest: VSTest Version


version:Latest

The custom adapters path is empty, but the tooltips say Nuget restored adapters are automatically searched for.

Report options

Platform: $(BuildPlatform)


Configuration:$(BuildConfiguration)

So, it seems to me that it can find the file it needs (MyClassLibrary.Tests.dll), but it doesn't pick up test methods (which are marked as [Fact]

or [Theory

]).

Does anyone have an idea what I am doing wrong?

Update

All projects in solution .NET 4.5

+3


source to share


2 answers


I had the same problem, once I made the switch to xUnit, after a lot of trial and error and searching, I found that the xUnit test runner can only be run in assembler targeting .NET 4.5.2 or higher, otherwise it cannot be loaded (and therefore no tests will be found).

The documentation is a bit vague here as the Getting Started with xUnit tutorial does not mention it, it only mentions creating a new class library project "targeting .NET 4.5.2 (or later)".



But this is only for the assembly containing the actual tests, your projects under test may still target .NET 4.5. In my case, I just switched my test assemblies to target .NET 4.5.2, but all other projects are still targeting .NET 4.5 and it works very well.

+3


source


Just an update on this as I recently had this issue and was unable to get the VsTest runner to open my xnet tests. Core Core 2.0.

Note: the VsTest runner works fine locally on my machine, but not from VSTS - even if there are adapters for xunit testing.



Anyway, use the .NET Core build task instead - it's pretty easy to use. Basically:

  • Add .Net Core create task (atm preview)
  • Change command to check
  • Add path to your test projects - eg. ** / * Tests.csproj
  • Any additional arguments - for example --filter "Category! = Integration"
  • There is also an option to publish test results which will create a trx output file
+4


source







All Articles