You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Visual Studio+ReSharper运行单元测试报错:测试用例对象缺失及相关问题

Fixing ReSharper & Visual Studio Unit Test Issues: Missing Test Cases, Skipped Tests, and Inconclusive Results

Let’s walk through the most effective fixes for the frustrating issues you’re facing—missing test cases, skipped tests, "Inconclusive: Test not run" messages, and that grey eye icon in ReSharper that won’t let you run tests.

Step 1: Clean and Rebuild Your Entire Solution

The error message explicitly calls out rebuilding, so let’s do this thoroughly:

  • Close any active test sessions in both ReSharper and Test Explorer first.
  • Go to Build > Clean Solution in Visual Studio to wipe old binaries.
  • Once cleaning finishes, run Build > Rebuild Solution (not just regular Build—Rebuild ensures every project is compiled from scratch).
  • After rebuilding, try launching your tests again via ReSharper’s test runner.

Step 2: Reset ReSharper’s Caches

Corrupted caches are a common culprit for test detection issues:

  • Open ReSharper’s settings: Go to Extensions > ReSharper > Options.
  • Navigate to Environment > General.
  • Click the Clear Caches button, then restart Visual Studio when prompted.
  • Let ReSharper finish indexing your solution fully (wait for the progress bar in the bottom right to disappear), then check if the missing tests reappear.

Step 3: Fix Test Explorer Sync Problems

If Test Explorer is missing 200+ tests, it’s likely out of sync with your solution:

  • Click the Refresh button (circular arrow icon) at the top of Test Explorer to force a rescan.
  • Try toggling the processor architecture: Go to Test > Test Settings > Default Processor Architecture and switch between x86 and x64—some test frameworks are tied to specific architectures.
  • Check if any test projects are excluded from the build: Right-click the test project in Solution Explorer > Properties > Under Configuration Properties > Configuration, make sure Build is checked.

Step 4: Double-Check Test Class/Method Attributes

Sometimes tests get skipped or undetected due to missing or incorrect attributes:

  • Verify your test classes have the right attribute: [TestClass] for MSTest, [TestFixture] for NUnit, or public class (no attribute needed for xUnit, but ensure it’s a public class).
  • Confirm each test method uses the correct marker: [TestMethod] (MSTest), [Test] (NUnit), [Fact]/[Theory] (xUnit).
  • Watch for typos—even a missing bracket or misspelled attribute can make tests invisible to runners.

Step 5: Repair Your Visual Studio Installation

If all else fails, a corrupted VS component might be the issue:

  • Open the Visual Studio Installer.
  • Select your installed VS version, click Modify.
  • Click the More dropdown and choose Repair.
  • Let the repair process run (it might take a while), restart your machine, then test again.

Step 6: Toggle ReSharper’s Test Runner Integration

Occasionally, toggling the integration resets glitches:

  • Go to Extensions > ReSharper > Options > Tools > Unit Testing.
  • Uncheck Enable Unit Testing Support, click Apply, then recheck it and apply again.
  • Restart Visual Studio and try running tests once more.

内容的提问来源于stack exchange,提问作者goku_da_master

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:38:11