Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2017 cannot discover MSTest tests

I've been having this recurring problem with some of my .Net framework 4.5 and 4.6 and 4.7 projects not having their tests discovered by test explorer. The "tests" log output is showing:

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

That's all the info I have.

I've tried pretty much every combination of the different version of MSTest.Framework and adapter and such. Just can't figure this one out. I've done the Test Extension cache clearing.

like image 372
Jerome Haltom Avatar asked Jul 26 '17 18:07

Jerome Haltom


People also ask

Is MSTest deprecated?

Test projects that are Coded UI tests or Web Load Tests are not compatible with MSTestV2. These project types have been deprecated.

How do I debug MSTest in Visual Studio?

To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.


2 Answers

I had upgraded some of the projects to 4.6.2 and two of them had app.config files with specific assembly bindings.

Deleting both the app.config files fixed the problem for me - there were no other settings being used in the files so I just deleted rather than fixing the bindings.

like image 89
Andy Cook Avatar answered Sep 22 '22 02:09

Andy Cook


I got the same issue. I am using VS 2017 and .Net Version 4.7. Though I made test runnable by adding Visual Studio Quality Tools and by removing MSTest framework and adapter packages, I am getting other issues like "Could not load System.Runtime"

Update: In my case, the root cause of getting this issue was deleting the <Target> tag in the test project's .csproj file. I got missing file nuget package error and resolved that issue as suggested here. Unfortunately it has a side effect that made my test methods non discover-able

like image 44
Saravanan Avatar answered Sep 23 '22 02:09

Saravanan