[c#] Test method is inconclusive: Test wasn't run. Error?

I have a test class and below I have posted a sample test from the test class

namespace AdminPortal.Tests.Controller_Test.Customer
{
    [TestClass]
    public class BusinessUnitControllerTests
    {
        private IBusinessUnitRepository _mockBusinessUnitRepository;
        private BusinessUnitController _controller;

        [TestInitialize]
        public void TestInitialize()
        {
            _mockBusinessUnitRepository = MockRepository.GenerateMock<IBusinessUnitRepository>();
            _controller = new BusinessUnitController(_mockBusinessUnitRepository);
        }

        [TestCleanup]
        public void TestCleanup()
        {
            _mockBusinessUnitRepository = null;

            _controller.Dispose();
            _controller = null;

        }

        #region Index Action Tests
        [TestMethod]
        public void Index_Action_Calls_GetAllBusinessUnit()
        {
            _mockBusinessUnitRepository.Stub(x => x.GetAllBusinessUnit());

            _controller.Index();

            _mockBusinessUnitRepository.AssertWasCalled(x=>x.GetAllBusinessUnit());
        }
    }
}

When I run the project I get following screen enter image description here

I checked the references and the test project has the reference to main project. Any idea why the test are not running or saying that they were inconclusive?

Edit 1:

I saw a post here and changed my test's setting's default processor architecture to X64 but it still doesn't work.

This question is related to c# asp.net-mvc asp.net-mvc-4 unit-testing resharper

The answer is


In my case, all tests within some test projects within a solution started not running after I added new projects. Using VS 2017 with ReSharper 2017.1.2 here.

First of all, make sure you're not wasting time assuming that your issue is ReSharper related. It is easy to assume that there's something wrong with ReSharper if you use its unit testing features including Unit Test Explorer. Open up Visual Studio's Test Explorer under the Test menu and try Run All". The added advantage of doing this is that the output window will show an error message that might point you in the right direction. If you notice that the same set of test are not run, then it is safe to assume that the issue is with Visual Studio and not ReSharper.

I ended up deleting and re-adding one of the Active solution platform, Any CPU, in Configuration Manager. By doing so, after saving my changes and reopening the solution, all tests started running again.

I believe there was an unexpected configuration entry in the solution file when I added new projects and by using recreating one of the platforms, it corrected itself. I tried diffing but it was difficult to tell what had changed to cause the issue.


Another one method of solving this problem:

Run tests in another environment (TeamCity for example) and see your REAL problem. My problem was incorrect binding redirect to System.Web.Mvc 5.2.6.0 (not installed on my machine).


For who are in rush for test execution, I had to use VS 2017 test explorer to run tests;

enter image description here

enter image description here


In my case (Visual Studio Community 2017 version 15.2) the source of issue was new way of loading projects introduced in VS 2017, i.e. 'Lightweight Solution Load'.

In "Unit Test Sessions" window I noticed that solution has way less tests then it should. I had to open each unit test project manually in "Solution Explorer" and only then all tests were loaded and passed.

One way to solve this is to disable "Lightweight Solution Load" by right clicking on solution in "Solution Explorer" and set "Disable Lightweight Solution Load".


In my case [Test] methods were just private. S-h-a-m-e


Have you added any DLL dependency recently? ... like me

I just ran into the same issue and it was very exasperating not to get any clue in the test output window or elsewhere practical.

The cause was extremely stupid: I just added the day before dependency to an additional external DLL in a sub-project, and the main project App indeed built and ran correctly after the change. But my unit tests are in a sister project to the main app, and thus had too the dependency on this changed sub project where the DLL was invoked... yet, the runtime location of the test project is not that of the main App! So changing the build to do copying of the missing DLL into the test runtime directory fixed the problem.


Caused by missing (not corrupt) App.Config file. Adding new (Add -> New Item... -> Application Configuration File) fixed it.


I had the exact same issue and nothing helped.

eventually I saw that I had a mismatch in my namespaces of the unit project and the unit test project.

The namespace of my unit project is unit.project and the test project was named unit.project.tests but the default namespace of the test was the same as the unit, both was unit.project.

Once I've updated the namespaces to be different (one namespace for each project) everything worked!


For me, one test created this error and it turned out I had unintentionally skipped the test. On the left of the screen, where you click to put a break point, you may notice that your test is set to be skipped (there's a microsoft icon to indicate this). I enabled the test and the error went away.


I had all tests from a single test class failing with this issue, all other were running well. Later I found an error in a [ignore] attribute in one the tests on this class.


Just in case none of the above options worked for anyone I fixed my instance of this error by noticing a corrupt entry in my App.Config due to a missing nuget package in the test project.


This problem started when I upgraded to .NET Core 1.1.0

Solved by adding the following dependency to the project.json of the test project:

"Microsoft.DotNet.InternalAbstractions": "1.0.500-preview2-1-003177"

I know this question has /several/ answers to it, but I have yet another unique answer that I haven't seen as a way to resolve it. I'm hoping this helps someone else out there.

To use the Unit Test Sessions, one external dependency is the Microsoft.Net.Test.Sdk, at some point in the VS pipeline the xunit.runner.visualstudio stopped working correctly for the ReSharper Unit Test Session flavor of test runner. The following is how I ended up with this problem, and how I solved it.

My issue and answer arose from seeing the Inconclusive when converting some of my net451 libraries into netStandard 2.0 in order to allow my team to develop in Core or Framework. When I went into the newly finished netStandard2.0 libraries and started converting their old unit test projects into the new solutions, I ran into issues. You can't run Unit Tests in a net Standard project, so I chose to downshift to net472 for my unit testing projects.

At this point I'll note, .csproj files have gone through a change since .net Framework. In order to cleanly integrate with build packs for nupkg files and .net Standard libraries, you need to change your references to be handled with PackageReference instead of packages.config.

I had a few libraries coupled to Windows that couldn't be converted to netStandard, so when updating their dependencies to use the new netStandard libs, I realized that the dotnet pack command would fail if their .csproj files were in the old format. To fix that, not only did they need to be converted to PackageReference from packages.config, I had to manually update the .csproj files to the newer VS2017 format. This allowed those libraries to build into nuget packages cleanly as net472 libraries referencing netStandard2.0 dependencies.

There is a tool to convert the package organization behavior for you, it keeps the old .csproj style and uses the PackageReference in the .csproj. And due to the above I got in the habit of migrating the .csproj style to the VS2017 format manually.

So in summary, I was receiving the Inconclusive when I was using both PackageReference for my dependencies AND my Unit Testing Project .csproj file was in the VS2017 style.

I was able to solve this by deleting my project, recreating it exactly as it was in net472 and instead of converting it to the VS2017 .csproj format, I left it in the old format.

The old format, for whatever reason, allows my Test Session to complete.

I'm curious of few things:

  1. If a lot of the people with this issue were experiencing it in netCore versions where the .csproj files come in the new format by default.
  2. If people able to solve the issue by other means than my reproduceable problem/fix were on the netCore versions of .csproj and using netCore as their test project as well.
  3. If this solution will help any of the people that weren't able to fix it through rebuilds or deletion of vs/bin folders or additional entries in their .csproj files.

I don't know that this answer is the one true solution that ReSharper would need to fix it for everyone, but it is reproduceable for me, and solves my problem to leave the unit test project as the old version of .csproj file, at least when I have a net472 unit test project referencing netStandard2.0 libraries.

It should also be noted that VS2017 .csproj files deprecates the need for an AssemblyInfo.cs file in the Properties folder, which I'm not sure if that causes issues for the Unit Test Sessions as well.


I had the same issue with resharper and I corrected this error by changing an option:

Resharper => Options => Tools => Unit Testing

I just had to uncheck the option "Shadow-copy assemblies being tested"


My solution:

NUnit 3.2.0 has some issues with Resharper - downgrade to 2.6.4:

update-package nunit -version 2.6.4

enter image description here

enter image description here

Sometimes Just try drop header(.h) file and reAdd it as source(.cpp) NOT rename. Test in resharp c++ && vs2019 ,Test Code is Here


In my case I created an async test method which returned void. Returning of Task instead of void solved the issue.


In my case my test method was private I changed it to public and it worked.


I'm using VS2010, NUnit 2.6.3 (although internally ReSharper says it's using 2.6.2?), ReSharper 7.7.1 & NCrunch 2.5.0.12 and was running into the same "...test is inconclusive..." thing with NUnit, but NCrunch said everything was fine. For most of today NUnit & NCrunch were in sync agreeing about which tests were happy and which needed refactoring, then something happened which I still don't understand, and for a while NCrunch said I had failing tests (but stepping through them showed them to pass), then decided they were all working, and NUnit started complaining about all my tests except one with the same message "..test is inconclusive..." which I was again able to single step through to a pass even though NUnit continued to show it as "inconclusive").

I tried several of the suggestions above to no avail, and finally just closed VS2010 & reopened the solution. Voila, now all my tests are happy again, and NCrunch & NUnit are reporting the same results again. Unfortunately I have no idea what changed to cause them to go out of sync, but closing & reopening VS2010 seems to have fixed it.

Maybe someone else will run into this and be able to use this simple (if ultimately unsatisfying since you don't know what the real fix is) solution.


In my case i got this error because of 'Release' mode where build of UnitTests project was simply switched off. Switching back to 'Debug' mode fixed it.

It's really surprising that ReSharper cannot say anything in case it cannot find UnitTests library at all. Seriously, it's a shame;)

Hope it will help somebody


I was having this problem, and it turned out to be the same as this problem over here. This answer solved the problem for me.

  1. Uncheck "Only build startup projects and dependencies on Run" (Options -> Projects and Solutions -> Build and Run)
  2. In Configuration Manager, make sure both the start-up project and the Test project have "Build" checked.

The second time I hit this issue, it was due to an ampersand in the filepath to the project where the tests reside. It works fine with ReSharper's test runner, but not dotCover's. Remove the ampersand from the filepath.

This is a confirmed bug with dotCover.


I just fixed this issue as well. However, none of the solutions in this thread worked. Here's what I did...

Since R# wasn't giving any detail about why things were failing, I decided to try the built-in VS2013 test runner. It experienced the exact same behavior where none of the tests ran. However, looking in the Output window, I finally had an error message:

An exception occurred while invoking executor 'executor://mstestadapter/v1': Object reference not set to an instance of an object.

This led me to another thread on SO with a solution. Believe me, I would have NEVER guessed what the issue was.

I had recently made a few changes to the AssemblyInfo.cs file while creating a NuGet package. One of the changes including specifying an assembly culture value of "en".

I changed this:

[assembly: AssemblyCulture("")] 

to this:

[assembly: AssemblyCulture("en")]`. 

That was it! That's what inexplicably broke my unit tests. I still don't understand why, however. But at least things are working again. After I reverted this change (i.e. set the culture back to ""), my tests began running again.

Hope that helps somebody out there.


For those still not able to solve their issue, check the Consolidate tab when managing your Nuget packages.

Turned out our unit test project referenced a different version causing this completely vague error.


I'm was having the same problem to run any test using NUnit framework. "Inconclusive: Test not run" Visual Studio 2017 15.5.6

ReSharper Ultimate 2017.3.3 Build 111.0.20180302.65130

SOLVED Adding project dependency to Microsoft.NET.Test.Sdk


In my case, ReSharper gave me this additional exception in the test window:

2017.06.15 12:56:57.621   ERROR Exploration failed with the exception:
System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at JetBrains.ReSharper.UnitTestFramework.Launch.Stages.DiscoveryStage.Run(CancellationToken token)
---> (Inner Exception #0) System.Threading.Tasks.TaskCanceledException: A task was canceled.<---

it ended up that the test projects giving this error both were not set to build at all in the Configuration Manager. Checking the checkbox to build the 2 test projects and rebuilding sorted for me.

enter image description here


In my case found that the TestCaseSource has different number of argument than the parameter in test method.

[Test, TestCaseSource("DivideCases")]
public void DivideTest(int n, int d, int q)
{
    Assert.AreEqual( q, n / d );
}

static object[] DivideCases =
{
    new object[] { 12, 3 },
    new object[] { 12, 2 },
    new object[] { 12, 4 } 
};

Here each object array in DivideCases has two item which should be 3 as DivideTest method has 3 parameter.


For me it was rather frustrating, but I've found solution for my case at least:

If your TestMethod is async, it cannot be void. It MUST return Task.

Hope it helps someone :)


I had a version mismatch in my nuget dependencies between projects in a solution. Using the consolidate feature in Visual Studio helped identify and fix this.


I am using VS2013, ReSharper 9.1 with MSpec extension from ReSharper and Moq. I experienced the same "inconclusive" error.

It turned out the one of my Mock's from Moq was not initialized, only declared. Ones initialized all tests ran again.


In my case, I referenced 2 projects from my unittestproject. Both referenced projects used a dll with the same name, but with a different version.

I did not notice this in Visual Studio. I noticed the error in the Eventviewer.

To solve this, I used bindingRedirect in the app.config of the unittestproject to fix the dll-version.


My issue has been solved by the most superficial solution:

Add the Moq nuget package to the test project solve the inconclusive test method, and you can remove the nuget package afterwards.

After adding the Moq package my test method runs with the following nuget packages: Castle.Core (4.4.0), Moq (4.13.1), NUnit (3.12.0), System.Runtime.CompilerServices.Unsafe (4.5.0) and System.Threading.Tasks.Extensions (4.5.1)

After removing most of the above nuget packages my test method still runs with only NUnit (3.12.0).

Appreciate if someone figures out why this happens.


Hope it'll help other, my fix was to update packages, there was a consolidation, and making all work with same packs fixed this issue for me. GL!


For me the issue was an asynchronous call which was not waited in any way.

   dc.Start(); // Asynchronous, it is mocked on this particular test, so i did not bother blocking the test.

Changed it to :

   dc.Start().ContinueWith(t =>
   {
        waitHandle.Set();
   });

   waitHandle.WaitOne(60000); // wait dc start

And the test began to be applicable again.


For me, the problem was a corrupt NUnit/ReSharper settings XML-file (due to an unexpected power shortage).

To identify the error I started Visual Studio with this command:

devenv.exe /ReSharper.LogFile C:\temp\resharper.log /ReSharper.LogLevel Verbose

Examining the file revealed the following exception:

09:45:31.894 |W| UnitTestLaunch                | System.ApplicationException: Error loading settings file
System.ApplicationException: Error loading settings file ---> System.Xml.XmlException: Root element is missing.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(String filename)
   at NUnit.Engine.Internal.SettingsStore.LoadSettings()
   --- End of inner exception stack trace ---
   at NUnit.Engine.Internal.SettingsStore.LoadSettings()
   at NUnit.Engine.Services.SettingsService.StartService()
   at NUnit.Engine.Services.ServiceManager.StartServices()
   at NUnit.Engine.TestEngine.Initialize()
   at NUnit.Engine.TestEngine.GetRunner(TestPackage package)
   at JetBrains.ReSharper.UnitTestRunner.nUnit30.BuiltInNUnitRunner.<>c__DisplayClass1.<RunTests>b__0()
   at JetBrains.ReSharper.UnitTestRunner.nUnit30.BuiltInNUnitRunner.WithExtensiveErrorHandling(IRemoteTaskServer server, Action action)

Note that this is NOT the test project's app.config!

A quick googling around identified the following file as the culprit:

%LOCALAPPDATA%\NUnit\Nunit30Settings.xml

It existed, but was empty. Deleting it and restarting Visual Studio solved the problem.

(Using Visual Studio Professional 2017 v15.3.5 and ReSharper 2017.2.1).


For me, simply cleaning and rebuilding the solution fixed it.


I had the same error in VS2013 and Resharper9. The problem was because i forgot to annotate test method with [Test] :) Hope this helps anyone


In my case it was due to passing in \r\n characters inside TestCase's. Not sure why it's causing intermittent issues, as it works most of the time. But if I remove \r\n the test is never inconclusive:

[TestCase("test\r\n1,2\r\n3,4", 1, 2)]
public void My_Test(string message, double latitude, double longitude)

I had this same issue. The culprit was an external reference not being compatible with my project build settings. To resolve, I right clicked on the project->properties->build->Platform Target-> change from Any CPU to x86.

The particular *.dll that I was working with was System.Data.SQLite. That particular *.dll is hardcoded for 32 bit operation. The "Any CPU" setting attempted to load it as 64 bit.


This error occurred with Visual Studio 2017 and resharper version 2018.2.3 but the fix applies to Visual Studio 2019 versions to.

The fix, to get tests working in Resharper, was simply to update to the latest version of Resharper (2019.2.1) at the time of writing.


I had the exact same problem, no tests were run in my test-project. As it happend I had the wrong configuration selected when running the tests. Changing it back to Debug fixed the problems.

Debug configuration


In my case it was a mistake i did while copying the connectionstring in the app.config.. I had put it inside the configSections tag!

Took me a while to realize that... thanks VS intellisense though.. or was it resharper?


For those who are experiencing this issue for my test project .NET Core 2.0 in the Visual Studio 2017 Community (v15.3 3). I also had this bug using JetBrains ReSharper Ultimate 2017.2 Build 109.0.20170824.131346 - there is a bug I posted.

JetBrains advised to create a new test project from scratch to reproduce it. When I did that and got tests working OK, I found the reason causing the issue:

  • Remove this from your *.csproj file:
  • Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}"

When I did that - tests started working fine.


I had the same problem.It was related to compatibility version between NUnit 3.5 and Resharper 9.2,since it was solved by downgrading from NUnit 3.5 to 2.6.4. It worked for me. good luck.


I had similiar issue. VS 2010, c# CLR 2 Nunit 2.5.7 , just build > clean solution from VS helped to resolve this issue


My problem was that I had only installed NUnit with nuget. I hadn't installed NUnit3TestAdapter which was also required.

Install-Package NUnit3TestAdapter

I faced this problem in vs 2017 update 3 with Resharper Ultimate 2017.2

Restart vs or restart machine can't help.

I resolved the problem by clearing the Cache as follows:

    Resharper ->options-> Environment ->click the button 'Clear caches'

Update:

There is a button "error" (I find in Resharper 2018) in the upper right corner of the test window.

If you click the error button, it shows an error message that may help in resolving the problem.

To track the root of the problem, run Visual Studio in log mode. In vs 2017, Run the command:

      devenv /ReSharper.LogFile C:\temp\log\test_log.txt /ReSharper.LogLevel Verbose

Run the test.

Review the log file test_log.txt and search for 'error' in the file.

The log file is a great help to find the error that you can resolve or you can send the issue with the log file to the technical support team of Resharper.


I used the ReSharper Build to fix this.

ReSharper => Options => Tools => Build => General => Use ReSharper Build

If you are using xUnit, I solved the issue installing xunit.running.visualstudio package. (currently using xUnit 2.3.1 and VS17 Enterprise 15.3.5)


All the test for my class became inconclusive after some code changes (they were passing previously).

It appeared that I had added a new field to my testing class:

private readonly Foo _foo = CreateFoo();

The problem was that an exception was thrown inside 'CreateFoo()', so it happened for all the tests and instead of failing they all became inconclusive.


In my case I had an error in my application configuration file app.config. I had misplaced appsettings above the configSections instead of placing it inside. So a corrupt configuration file could be the cause of Resharper not running your tests responding Inconclusive.


Very strange behavior.

Just moved a new appsetting entry recently added to the bottom of the app.config solved my issue.

<appSettings>
    <add key="xxxxxx" value="xxxxx" />
</appSettings>

Hope this helps someone


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to asp.net-mvc

Using Lato fonts in my css (@font-face) Better solution without exluding fields from Binding Vue.js get selected option on @change You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to send json data in POST request using C# VS 2017 Metadata file '.dll could not be found The default XML namespace of the project must be the MSBuild XML namespace How to create roles in ASP.NET Core and assign them to users? The model item passed into the dictionary is of type .. but this dictionary requires a model item of type How to use npm with ASP.NET Core

Examples related to asp.net-mvc-4

Better solution without exluding fields from Binding How to remove error about glyphicons-halflings-regular.woff2 not found When should I use Async Controllers in ASP.NET MVC? How to call controller from the button click in asp.net MVC 4 How to get DropDownList SelectedValue in Controller in MVC Return HTML from ASP.NET Web API There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key country Return JsonResult from web api without its properties how to set radio button checked in edit mode in MVC razor view How to call MVC Action using Jquery AJAX and then submit form in MVC?

Examples related to unit-testing

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 How to test the type of a thrown exception in Jest Unit Tests not discovered in Visual Studio 2017 Class Not Found: Empty Test Suite in IntelliJ Angular 2 Unit Tests: Cannot find name 'describe' Enzyme - How to access and set <input> value? Mocking HttpClient in unit tests Example of Mockito's argumentCaptor How to write unit testing for Angular / TypeScript for private methods with Jasmine Why is the Visual Studio 2015/2017/2019 Test Runner not discovering my xUnit v2 tests

Examples related to resharper

Tests not running in Test Explorer Test method is inconclusive: Test wasn't run. Error? Visual Studio displaying errors even if projects build Keyboard shortcuts are not active in Visual Studio with Resharper installed Where do I mark a lambda expression async? What does CultureInfo.InvariantCulture mean? Handling warning for possible multiple enumeration of IEnumerable Why should I use var instead of a type? How do I generate a constructor from class fields using Visual Studio (and/or ReSharper)? What are some alternatives to ReSharper?