vstest.console.exe discovers no tests for a .NET Core class library project (VS 2017 RTM)

Created on 10 Mar 2017  路  15Comments  路  Source: microsoft/vstest

Description

After creating a brand new .NET Core class library and unit test project, the IDE discovers my test, but not the console.

Steps to reproduce

A project created using the steps below is available from this link.

  1. Create new Class Library (.NET Core).
  2. Add a new static method to Class1 that can be called from an external module.
  3. Right-click the solution and add a new Unit Test Project (.NET Core) project to it.
  4. Right-click the unit test project and add the library as a reference.
  5. Add an assertion test to the unit test project.
  6. Build the solution. (The test in your test project should show up in the VS Test Explorer.)
  7. Execute tests with code coverage, through the IDE or command line:
    vstest.console.exe "C:\...\bin\Debug\netcoreapp1.1\UnitTestProject1.dll" /UseVsixExtensions:true /logger:trx

    • I have also tried the above command with /Framework:FrameworkCore10 per #579; the result is the same

Expected behavior

The single test in the project, TestMethod, should execute and pass.

Actual behavior

Starting test execution, please wait...
Warning: No test is available in C:\...\bin\Debug\netcoreapp1.1\UnitTestProject1.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.

Environment

  • Windows 10 (15031 Insider build)
  • Visual Studio 2017 RTM 15.0.0-RTW+26228.4
  • vstest.console.exe 15.0.26228.0

Most helpful comment

@smadala Great, those two fixes together work.

What is the difference between the vstest.console.exe on the Developer Console and the C:\...\vstest.console.exe path you provided? Why do we have to specify?

All 15 comments

@ekumlin from https://github.com/Microsoft/vstest/issues/443#issuecomment-277467717, to run .Net Core tests project, please use vstest.console.exe from folder C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\.

Edit: From VS 2017 update 5, All the requests to TPv1 forwards to TPv2.

TP v1:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindowvstest.console.exe

TP v2: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatformvstest.console.exe

Thank you for the reply. Unfortunately, this does not work either.

>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" "C:\...\bin\Debug\netcoreapp1.1\UnitTestProject1.dll" /logger:trx
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
No test is available in C:\...\bin\Debug\netcoreapp1.1\UnitTestProject1.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.

I also tried with /UseVsixExtensions:true, but that provided an error:

The test source file "/UseVsixExtensions:true" provided was not found.

@ekumlin For .Net Core project, /Frameowrk:FrameworkCore10 should be provided when running with vstest.console.exe

Edit: From vstest 15.5 onwards, /Framework argument is not required for .NET Core targeted tests.

@smadala Great, those two fixes together work.

What is the difference between the vstest.console.exe on the Developer Console and the C:\...\vstest.console.exe path you provided? Why do we have to specify?

@smadala Hi I just want to ask something this is a bit irrelevant to the current topic but I hope you can help me.

Why is it that I can't add a new capability on a certain build agent (this is a private pipeline). I tried adding a new one but it doesn't displays on the list of capabilities.

Is there any work around on this?

@lorenz31 Sorry, I don't have idea about it. Can you pose your question here? See the doc helps?

Here's a screenshot of what I mean.
screenshot

As you can see the Save Changes and Undo Changes buttons are disabled. That's when I added the new capability.

Also the "here" link isn't available.

Edited the link

The link is still not available.

Thanks works now! :)

I found that the my older mstest csproj files didn't include various targets needed for VSTO to find unit tests. I created a new MSTest project and compare that with the existing csproj files and found a stack of references that needed to be copied to my older projects.

E.g.
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />

I am trying to run vstest.console.exe for a Xamarin UI test project and I am getting message
Starting test execution, please wait...
No test is available in E:\UnitTests\XFUITest\bin\Debug\Xamarin.UITest.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

I am using Enterprise version of VS2017 15.4.4.
command I am using is

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform>vstest.console.exe E:\UnitTests\XFUITest\bin\Debug\Xamarin.UITest.dll /logger:trx

Can you please help @smadala

@pMaske What is target framework of Xamarin.UITest.dll? Can you please create separate issue with all details in Issue template?

Was this page helpful?
0 / 5 - 0 ratings