Test Explorer fails to show tests. Tests output: "The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)"
See original GitHub issueDescription
I cloned a private Git repo on my local machine. The solution comprises of several projects all targeting .NET 4.6.2. I built the solution which pulled-in some NuGet packages, including MSTest.TestAdapter, 1.1.18
and MSTest.TestFramework, 1.1.18
. There is a test project in the solution with several [TestClass]
/[TestMethod]
tests. The solution builds successfully, however the Test Explorer window is empty. On a coworker’s machine running VS2015 the Test Explorer is populated correctly.
In the Output window’s Test output I see the following:
------ Discover test started ------ The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) ========== Discover test finished: 0 found (0:00:00.1886778) ==========
Steps to reproduce
I have no specific reproduction steps - it happened spontaneously on my machine. Restarting VS, cleaning the project output and TestResults
directory, and closing+reopening the Test Explorer window has no effect.
Expected behavior
The tests in the project should appear in Test Explorer.
Actual behavior
No tests appear in Test Explorer, and an error message in the Output window.
Environment
Please share additional details about the test environment. Operating system, Build version of vstest.console, Package version of MSTest framework and adapter
- Windows 10 x64 Enterprise, Creators Update
- Visual Studio 2017 Enterprise, 15.2
- MSTest package version 1.1.18
- Projects targeting .NET 4.6.2
- I have two copies of
vstest.console
installed:C:\Program Files (x86)\Microsoft Visual Studio 15.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
-15.0.26228.0
- 142KBC:\Program Files (x86)\Microsoft Visual Studio 15.0\Common7\IDE\Extensions\TestPlatform\vstest.console.exe
-15.0.0.0
- 117KB
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:101 (45 by maintainers)
Top GitHub Comments
I generated the fusion logs - I had a quick look but I couldn’t see any errors.
I do have another test project that works fine and its tests do appear in the Test Explorer window - so I compared the two projects. I noticed they’re both .NET Framework 4.6.2 projects, however the working project has a reference to
Microsoft.VisualStudio.QualityTools.UnitTestFramework
which is being pulled fromC:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
- whereas the non-working project has a reference toMicrosoft.VisualStudio.TestPlatform.TestFramework
which is being pulled from(solution root)\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
.Indeed, the working project is using a standard Visual Studio Test project which came with its own VS-coupled references, while the non-working project is using the NuGet “MSTest V2” assemblies instead.
So why is MSTest V2 not working all of a sudden?
TL;DR Workaround:
Microsoft.VisualStudio.TestPlatform.TestFramework
.Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
assembly instead, which is located inside your Visual Studio installation directory (Common7\IDE\PublicAssemblies
).Just want to report that I had the same problems in a newly created project. The app.config used to be empty, but after installing some packages assemblybinding’s must have gotten added, which was causing the problem.
The solution was simple - I deleted the whole runtime section and cleared the output folders (bin, obj and TestResults), then it was working again. Tried adding the assemblybindings again and got the same error.