54
votes

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.

11
Try changing your test project's platform target to AnyCPU.Kit
Yep, that was it! Wish I would have asked this question yesterday. I had already found the solution a little before posting this question. If you want to post your answer I'll delete mine.goku_da_master
If you are using ReSharper, reinstalling it helped.Skorunka František
I just had this, behaviour was different: old test worked, new did not. Inspired by one of the other answers about reinstalling mstest I found that my mstest-framework and adaptor were outdated. Upgrading them resolved my issue.Gavin

11 Answers

46
votes

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

18
votes

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.

5
votes

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.

3
votes

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

2
votes

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

1
votes

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.

1
votes

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.

0
votes

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.

0
votes

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.

0
votes

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>
0
votes

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.