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

VS2013的NUnit v2.x测试无法在VS2017测试资源管理器中显示

Troubleshooting NUnit v2.x Tests Not Showing in VS2017 Test Explorer

Hey there, I’ve dealt with this exact NUnit version compatibility snag before— let’s walk through the fixes that worked for me and other devs:

1. Fix Version Compatibility Between NUnit and Test Adapter

NUnit 3’s test adapter (NUnit3TestAdapter) doesn’t fully support NUnit 2.x test syntax out of the box. You’ve got two solid paths here:

If you’re open to updating your test code:

  • Uninstall the current NUnit v3.10.1 and NUnit3TestAdapter v3.10.0 NuGet packages from your test project
  • Reinstall the latest compatible versions of NUnit and NUnit3TestAdapter (stick to matching major versions for best results)
  • Tweak your test code to use NUnit 3 syntax:
    • Swap [TestFixtureSetUp] with [OneTimeSetUp]
    • Swap [TestFixtureTearDown] with [OneTimeTearDown]
    • Most assertion methods like Assert.AreEqual are backward compatible, but double-check any niche NUnit 2-specific calls

Option B: Stay on NUnit 2.x

If you need to keep the original test code as-is:

  • Uninstall NUnit v3.10.1 and NUnit3TestAdapter entirely
  • Install the exact NUnit 2.x version used in the original VS2013 project (e.g., v2.6.4) via NuGet
  • Install the NUnit Test Adapter (not the 3.x version— look for the package named NUnitTestAdapter, typically v2.0.0 or later that supports NUnit 2.x)

2. Align Processor Architecture Settings

Your VS2017 default is set to X64, but your test project builds for X86— this mismatch often blocks test discovery:

  • Go to the Test menu in VS2017
  • Select Test Settings > Default Processor Architecture > choose X86 to match your project’s "Active Solution Platform" setting

3. Clean Up Cached Build Files & Rebuild

Sometimes stale build files cause issues that a basic clean/rebuild misses:

  • Delete the bin and obj folders directly from your test project directory
  • Restart Visual Studio
  • Do a full clean (Build > Clean Solution) followed by a rebuild (Build > Rebuild Solution)

4. Quick Attribute & Project Check

Even though you mentioned attributes are correct, a quick verify won’t hurt:

  • Ensure your test class has the [TestFixture] attribute (required for NUnit 2; NUnit 3 allows omitting it, but keeping it works)
  • Confirm each test method is public and decorated with [Test]
  • Make sure your test project is set to Class Library as its output type (right-click project > Properties > Application > Output type)

Start with the version compatibility fix— that’s the most common culprit here. If you work through these steps one by one, your tests should pop up in the Test Explorer in no time!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:16:02