Error when running unit tests in visual studio: Test-case objects missing

C#.NetVisual StudioResharperMstest

C# Problem Overview


I'm getting the following error when running unit tests from visual studio using resharper:

Test-case objects missing for the following elements: ... Rebuild the project and try again

In the tooltip next to the unit test method it says: Inconclusive: Test not run and I think it said Unit test skipped at one point. Resharper shows a grey eye icon.

There's also a wierd issue with visual studio's Test Explorer. It won't show all my unit tests. In fact, it's missing over 200 of my unit tests. They just don't appear in the Test Explorer window. I do have a handful of tests that appear and will run just fine.

Things I've tried already: rebooting my machine, clean, rebuild, changing all dependent projects to use the same .net framework 4.7.

I'm using VS 2017 .net Framework 4.7, Resharper, and MSTest. All with the latest updates and versions.

C# Solutions


Solution 1 - C#

I experienced this error after removing all nuget packages as I had changed my .net version and did not need any of them to compile.

After re-installing the MSTest.TestAdapter nuget package ReSharper started running my unit tests again as expected.

Install-Package MSTest.TestAdapter

Solution 2 - C#

I know this won't answer the OP's question, since he/she has tried it, but maybe it will help someone else.

For me a simple restart of Visual Studio solved the Test-case objects missing for the following elements: ... Rebuild the project and try again problem.

Solution 3 - C#

After banging my head for a day I got Test Explorer working. It was the target Platform.

In the unit test project properties, under Build, I had the Platform target as x64. I switched it to AnyCPU and Test Explorer immediately picked up my missing unit tests. However, resharper is still giving me the same error. I'll update if I find solution for it. In the mean time, I can at least run and debug my unit tests now.

Solution 4 - C#

For me this happened because I installed the Nuget package for FLEE, this inserted the following line into my app.config file of my test project:

<dependentAssembly>
  <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>

As I do not have version 4.1.2.0 installed on my machine (I have 4.0.0.0) somewhere the test project fails with this very confusing 'error message'

Once I installed an earlier version (1.05) of the FLEE package (which uses 4.0.0.0) and I changed the version number to 4.0.0.0 in the bindingRedirect in my app.config, all was sane again

Solution 5 - C#

I upgraded MSTest.TestAdapter from 1.1.18 to 1.3.2. It solved it for me finally.

Solution 6 - C#

My problem was using the wrong build configuration.

My solution has quite a few projects and quite a few different build configurations, I had inadvertently selected the wrong project configuration which was not properly setup to include the test project I was trying to use.

Solution 7 - C#

I encountered this when using an F# project. In my case it was the inclusion of brackets in the test method name that caused the issue;

[<TestMethod>]
member x.``E is updated where generic form or visit should include (this) UPDATED VISIT AND FORM``() =
        let origExpr = "visit:form:INTQ1AB"
        let checkedExpr = "VISIT2:FormFour:INTQ1AB"
        ...

resulted in an Inconclusive test whereas removing the brackets around '(this)' as below

[<TestMethod>]
member x.``E is updated where generic form or visit should include this UPDATED VISIT AND FORM``() =
        let origExpr = "visit:form:INTQ1AB"
        let checkedExpr = "VISIT2:FormFour:INTQ1AB"
        ...

allowed the test to complete successfully.

Solution 8 - C#

I ran into this issue when I let Resharper search for missing references for Nunit via NuGet. Instead of downloading the .NET core compatible version of the package which I needed, it had grabbed the .NET framework version. I uninstalled the NUnit package and reinstalled using NuGet package manager to resolve this.

Solution 9 - C#

After cloning a solution onto a new machine, I encountered this error. The problem was that I did not have the specified dotnet framework installed - I'd only installed 2.1 and 3.0 and it required 2.2. In fairness, the error in the Test output did report this:

Testhost process exited with error: It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.2.0' was not found.
  - The following frameworks were found:
      2.1.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      3.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The .NET Core frameworks can be found at:
  - https://aka.ms/dotnet-download
. Please check the diagnostic logs for more information.

Note that Visual Studio required a restart after installing the missing framework.

Solution 10 - C#

I had this problem when I updated some test projects to use the new format of project files, some of these projects still needed to include app.config files, when running the tests I was getting these messages

  • Test-case objects missing for the following elements ...
  • Test-case is missing. Rebuild the project and try again

Removing all the assembly bindings in the runtime section in the app.config fixed it for me - i.e. remove entries like this in the runtime section

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>

Solution 11 - C#

The error should be visible in Output window in Visible Studio. You may need to change to verbosity in the options.

In my case it was because I was referencing a dll without a strong name.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiongoku_da_masterView Question on Stackoverflow
Solution 1 - C#workabyteView Answer on Stackoverflow
Solution 2 - C#gabrielkerekesView Answer on Stackoverflow
Solution 3 - C#goku_da_masterView Answer on Stackoverflow
Solution 4 - C#Daniël TulpView Answer on Stackoverflow
Solution 5 - C#ekenmanView Answer on Stackoverflow
Solution 6 - C#Richard MooreView Answer on Stackoverflow
Solution 7 - C#pilsdumpsView Answer on Stackoverflow
Solution 8 - C#drobisonView Answer on Stackoverflow
Solution 9 - C#Lee OadesView Answer on Stackoverflow
Solution 10 - C#rpg IIView Answer on Stackoverflow
Solution 11 - C#ekimplView Answer on Stackoverflow