4

I have a built dll file for a test project in .net framework 4.6.

The test runs fine when I do vstest.console.exe test.dll but when I do dotnet vstest test.dll it says

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

I want to run coverlet on the dll but it seems like that won't work until I get dotnet vstest to work.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
agentq15
  • 105
  • 2
  • 5

3 Answers3

8

I was sort of able to reproduce your problem, though in my case I could not get either vstest.console.exe test.dll or dotnet vstest test.dll to work. they both just spat out the same error about no tests being available.

Issue reproduction:

  • Use NUnit as the testing framework.

Fix:

  1. Add a reference to Nunit3TestAdapter in packages.config
    <?xml version="1.0" encoding="utf-8"?>
    <packages>
      <package id="NUnit" version="3.12.0" targetFramework="net46" />
      <package id="NUnit3TestAdapter" version="3.16.1" targetFramework="net46" developmentDependency="true" />
    </packages>
  1. Rebuild the solution.

Then both of the commands vstest.console.exe test.dll and dotnet vstest test.dll worked as expected.


If you are using a different testing framework than NUnit, there ought to be a corresponding adapter to serve the same purpose.

I have verified that this works for MSTest as well.

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="MSTest.TestAdapter" version="2.1.0" targetFramework="net46" />
  <package id="MSTest.TestFramework" version="2.1.0" targetFramework="net46" />
</packages>
weshouman
  • 632
  • 9
  • 17
Kirk Horton
  • 368
  • 1
  • 7
  • We are using Microsoft.VisualStudio.TestTools.UnitTesting – agentq15 Feb 13 '20 at 08:47
  • 1
    @agentq15 that namespace belongs to the MSTest.TestFramework nuget package, whose corresponding adapter is MSTest.TestAdapter, so try that. i have verified that they work in tandem the same as NUnit in my answer. – Kirk Horton Feb 13 '20 at 14:05
1

I tried adding this adapter parameter (-a and path to the test adapter from the solution folder) in command and it worked:

dotnet test -a "..\packages\NUnit3TestAdapter.4.0.0\build\net35" --logger "trx;LogFileName=TestResults.trx" "..\bin\Debug\project.dll" 
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
0

Check if you have a generic method in your test class and remove it or move it somewhere else. This seems to break the tests.

Daniel P.
  • 809
  • 8
  • 15