Resolving "Test wasn't run" Error in Resharper with MSTest: Disabling Legacy Runner

Dec 07, 2025 · Programming · 9 views · 7.8

Keywords: Resharper | MSTest | Unit Testing

Abstract: This article addresses the common "Test wasn't run" error in C# unit testing, focusing on integration issues between Resharper and MSTest. Based on the best solution—disabling Resharper's legacy MSTest runner—and supplemented by other factors like async method return types, assembly shadow-copying, and corrupted configuration files, it provides a comprehensive troubleshooting guide. Structured as a technical paper, it covers problem reproduction, core solutions, supplementary causes, and preventive measures to help developers efficiently resolve test execution barriers.

Problem Background and Reproduction

In C# development environments, when using the MSTest framework for unit testing, developers often encounter test methods displaying "Test wasn't run" or "Inconclusive" statuses, preventing normal execution. This issue typically arises when integrating development environments (e.g., Visual Studio) with Resharper tools. Below is a typical problematic code example:

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);
        }

        [TestMethod]
        public void Index_Action_Calls_GetAllBusinessUnit()
        {
            _mockBusinessUnitRepository.Stub(x => x.GetAllBusinessUnit());
            _controller.Index();
            _mockBusinessUnitRepository.AssertWasCalled(x=>x.GetAllBusinessUnit());
        }
    }
}

When running such tests, the test results window may show error messages indicating that tests were not executed, despite correct code logic and configured project references. This issue not only affects test coverage but can also disrupt continuous integration workflows.

Core Solution: Disabling Resharper Legacy Runner

According to the best answer (Answer 4, score 10.0), the root cause of this problem lies in Resharper's MSTest integration settings. Resharper may default to enabling the "Use Legacy Runner" option, which can cause incompatibility with the latest versions of MSTest or the testing environment, thereby blocking test execution. The solution is as follows:

  1. Open the Resharper settings menu via: Resharper > Options > Tools > Unit Testing > MSTest.
  2. On the MSTest configuration page, locate the "Use Legacy Runner" checkbox.
  3. Uncheck this option to disable the legacy runner and enable Resharper's modern test running mechanism.
  4. Save the settings and rerun the test project. Typically, this action immediately resolves the "Test wasn't run" error, allowing tests to execute normally.

This method is based on common issues in Resharper 7 and above, but may vary slightly due to IDE version differences. After disabling the legacy runner, Resharper uses updated test adapters, improving compatibility with the MSTest framework and ensuring test methods are correctly identified and executed.

Supplementary Causes and Solutions

In addition to the core solution, other answers provide additional troubleshooting angles that can serve as supplementary references:

In-Depth Analysis and Preventive Measures

To fundamentally avoid the "Test wasn't run" error, developers should adopt the following preventive measures:

  1. Environment Consistency Check: Ensure compatibility between Resharper, Visual Studio, and MSTest test adapter versions in the development environment. Regularly update the toolchain to avoid using outdated plugins or runners.
  2. Test Code Standards: Follow MSTest best practices, such as correctly using [TestClass] and [TestMethod] attributes, and avoid unsupported return types (e.g., async void) in test methods. For async tests, always use async Task returns.
  3. Configuration Management: Maintain clean configuration files to avoid syntax errors from manual edits. Use NuGet package manager to handle dependencies, ensuring all referenced packages are correctly installed and synchronized.
  4. Tool Settings Optimization: In team development, standardize Resharper settings, particularly unit testing-related options. This can be done by exporting settings files or using version control to share configurations, reducing issues caused by environmental differences.

By combining the core solution with supplementary measures, developers can not only quickly resolve current errors but also enhance the reliability and maintainability of their test suites. In practical projects, it is recommended to first try disabling the legacy runner; if the issue persists, gradually investigate other potential causes.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.