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条回答
Animai°情兽
2楼-- · 2020-01-24 19:40

Disclaimer: it is not about xunit with visual studio 2015, but Visual Studio 2017 with a UWP unit test application (MSTest). I got to this thread searching the same thing so maybe someone else will do the same :)

The solution for me was to update the nuget packages for MSTest.TestAdapter and MSTest.TestFramework. It seems that when you create a unit test app for UWP you don't automatically get the latest versions.

查看更多
贪生不怕死
3楼-- · 2020-01-24 19:40

In my case I have multiple test projects in the same solution, and only one of the projects was not displaying the "Test Explorer"

I went to the "Manage Nuget Package for Solution" by right-clicking on the solution.

I noticed under the "Consolidate" tab there was some "Test" nuget packages that were out of sync between the projects. I clicked on "Install" and my missing tests showed up.

查看更多
Root(大扎)
4楼-- · 2020-01-24 19:41

Here is the solution that worked for us. Not the best but maybe one can benefit.

Background:

  • Our scripts were developed with VS 2013 and used NUnit VS Adapter 2.1..
  • Recently we migrated to VS 2017 and when open the same solution - test wouldn't show in the Test Explorer

Upon Build we would see this message:

[Informational] NUnit Adapter 3.10.0.21: Test discovery starting
[Informational] Assembly contains no NUnit 3.0 tests: C:\ihealautomatedTests\SeleniumTest\bin\x86\Debug\SeleniumTest.dll
[Informational] NUnit Adapter 3.10.0.21: Test discovery complete

Solution (temporary):

  • Uninstall NUnit Adapter 3.10...
  • Install NUnit VS Adapter 2.1..

Now the Tests are shown.

查看更多
可以哭但决不认输i
5楼-- · 2020-01-24 19:42

In my case, I created a new "Solution Configuration" like shown in the image. So when I select my custom one as "Prod", it doesnt recognize TestMehods for some reason. Changing back to "Debug" solves the problem

enter image description here

查看更多
小情绪 Triste *
6楼-- · 2020-01-24 19:42

I don't know if some of you also use JustMock, but I had to disable the profiler in VS 2017 for test detection to work.

查看更多
一夜七次
7楼-- · 2020-01-24 19:42

I tried most of the suggestions above and nothing worked. In my case, I'm on a team and tests were appearing for other devs for the same solution. So, I attempted just deleting my .vs folder, but no luck there either.

I ended up deleting my local folder entirely and re-cloning the repo. That solved it for me.

查看更多
登录 后发表回答