Why is the Visual Studio 2015/2017/2019 Test Runne

2020-01-24 19:06发布

UPDATE: Adding a 2019; the discovery/runner integration mechanism is same as per 2017 & 2015, so the key things that can go wrong are the same.


I've read Why is the xUnit runner not finding my tests, which covers reasons xUnit would never be able to find your tests but my problem is different - I'm confident there's nothing subtle going on with my tests; (they have worked in other environments, this seems to be just my machine) - the Visual Studio Test Runner in Visual Studio 2015 [Community Edition] is simply not showing any of my tests. I'm not doing anything remotely exciting; the tests target xUnit.net v2 on the Desktop.

I've looked in the Output window and am not seeing anything in at all under Test in the Show output from tabs.

30条回答
放荡不羁爱自由
2楼-- · 2020-01-24 20:01
  1. Close all Visual Studio instances
  2. Go to %TEMP%\VisualStudioTestExplorerExtensions\
  3. Delete specrun related folders
  4. Try again

let me know, thanks

查看更多
ゆ 、 Hurt°
3楼-- · 2020-01-24 20:03

I am using xUnit 2.2.0.

My issue was my solution was not able to find certain dlls and app.config was trying to resolve them. The error was not showing up in the test output window in Visual Studio.

I was able to identify the error when I installed xunit.runner.console and tried to run the tests through command line.

How to run xunit tests in CLI.

查看更多
Explosion°爆炸
4楼-- · 2020-01-24 20:03

Ran into a similar problem with VS not discovering test methods. In my case I had the static keyword with the method, which I removed and it worked.

[TestMethod]

Before: public static void Test1()

After: public void Test1()
查看更多
再贱就再见
5楼-- · 2020-01-24 20:05

Also check if a completely empty app.config file (completely blank with absolutely no markup) is within the test project. This was the culprit in my case.

查看更多
该账号已被封号
6楼-- · 2020-01-24 20:06

This can also be due to the build check box not being ticked for the current platform project in the build configuration. Click Build | Configuration manager, then make sure the test projects have a tick in the build column for the platform that you're using (for example 'x86').

This was definitely the solution that worked for me.

查看更多
Ridiculous、
7楼-- · 2020-01-24 20:06

I was suffering from this problem for long times.

  • I had about 100 projects different version was deployed in different server.

  • Updating xunit from 2.2.0 to 2.3.1 was not a solution because build was failing in 2.3.1.

Then I just updated xunit.runner.visualstudio to 2.3.1 and everything started to work fine. I have used this command in my package manager console to updated my xunit.runner.visualstudio package

Get-Project ComapanyName.ProjectName.*.Tests | Install-Package xunit.runner.visualstudio -Version 2.3.1
查看更多
登录 后发表回答