Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xunit Unit Tests will not run

I am completely stuck on this issue. So my team has a unit test project in a services test project. The tests are discovered in the test explorer pane however when I try and run the tests I get these errors:

'Multiple test adapters with the same uri 'executor://xunit/VsTestRunner2' were found. Ignoring adapter 'Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner'. Please uninstall the conflicting adapter(s) to avoid this warning'

'[xUnit.net 00:00:00.0251250] Skipping: (could not find dependent assembly 'Microsoft.Extensions.DependencyModel, Version=1.1.0')'

'No test is available in C:\. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.'

Context information:

  • Xunit 2.2.0
  • Visual Studio 15.5.2
  • Windows 10 1709 Build: 16299.125

My Test Projects project.json:

{    "version": "1.0.0-*",    "testRunner": "xunit",     "dependencies": {        "dotnet-test-xunit": "2.2.0-preview2-build1029",        "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.1.3",        "Microsoft.DiaSymReader": "1.0.8",        "Microsoft.DiaSymReader.Native": "1.4.1",        "Microsoft.Extensions.Logging.Abstractions": "1.1.2",        "Microsoft.Extensions.Testing.Abstractions": "1.0.0-preview2-003121",        "Newtonsoft.Json": "9.0.1",        "WebServices": "1.0.0-*",        "xunit": "2.2.0",        "xunit.abstractions": "2.0.1",        "xunit.assert": "2.2.0",        "xunit.core": "2.2.0",        "xunit.extensibility.core": "2.2.0",        "xunit.extensibility.execution": "2.2.0",        "xunit.runner.utility": "2.2.0"    },    "frameworks": {     "net461": {         "dependencies": {             "Microsoft.NETCore.Platforms": "1.1.0"         }     } } 

The Weird thing is that it works for my team members. But not me. The differences in our environments are: the latest update from Windows and Visual Studio, while they are an update or two behind.

Does anyone know of a workaround?

like image 841
CMR Avatar asked Dec 19 '17 20:12

CMR


People also ask

Why is xUnit skipping tests?

When you have the ignore attribute above a testmethod the test will be skipped. Now when you run your tests you will see that this test has been skipped. Indicated by the yellow exclamation mark.

How do I run xUnit test cases in Visual Studio 2019?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.

How do I run xUnit tests from command line?

From the command line, create a folder for your test project, change into it, and then create the project using dotnet new : $ mkdir MyFirstUnitTests $ cd MyFirstUnitTests $ dotnet new xunit The template "xUnit Test Project" was created successfully.


1 Answers

Installing or updating "xunit.runner.visualstudio" package did the trick for me. Until that, it was not working with framework 462.

like image 79
Pravin Avatar answered Sep 18 '22 17:09

Pravin