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

如何停止NUnit TestRunner?及NUnit测试异常问题求助

Hey there, let's work through this flaky NUnit test behavior you're dealing with in VS 2017 Enterprise. I’ve run into similar unpredictable test issues with older NUnit versions and TestDriven.Net combinations, so here are targeted fixes to try out:

1. Wipe Test Runtime Caches

Stale cached assemblies or state from NUnit/TestDriven.Net is a super common culprit for weird test behavior. Do this:

  • Close VS 2017 entirely, then delete the bin and obj folders across all projects in your solution to clear compiled outputs.
  • Navigate to %USERPROFILE%\AppData\Local\NUnit and delete everything inside this directory to purge NUnit's cached data.
  • Restart VS, rebuild your entire solution from scratch, then re-run your tests.
2. Verify TestDriven.Net & NUnit Version Compatibility

You’re using TestDriven.Net V4.1-Alpha—alpha builds often have unpatched bugs that clash with specific NUnit versions. Try:

  • Downgrading to a stable release of TestDriven.Net (like V3.0.x) that explicitly supports NUnit 3.x and .NET 4.0.
  • Or upgrading to the latest stable TestDriven.Net version to see if compatibility with NUnit 3.9/3.10 has been fixed.
3. Switch to VS’s Built-In Test Runner

TestDriven.Net isn’t your only option—VS 2017 has native support for NUnit tests. Let’s rule out TestDriven.Net as the issue:

  • Install the NUnit 3 Test Adapter via VS’s Extension Manager (search for it in the Extensions menu).
  • Disable or uninstall TestDrivenNet temporarily, then use VS’s Test Explorer to run your tests. If the unpredictability goes away, you know the problem lies with TestDrivenNet.
4. Check for Shared State in Your Tests

Even "simple" tests can fail if they rely on static variables, singletons, or shared external resources (like files, database connections) that don’t get reset between runs. Make sure:

  • Each test uses [SetUp] and [TearDown] attributes to reset static state or release shared resources before/after execution.
  • Tests are completely independent—no mutable objects or state should carry over from one test to the next.
5. Update VS & .NET Framework Patches

Old patches can cause compatibility glitches between VS 2017, .NET 4.0, and test tools:

  • Install all available updates for VS 2017 (go to Tools > Get Tools and Features > Updates).
  • Make sure your Windows 10 Pro is fully updated—system-level bugs can sometimes trickle up to affect test runtime behavior.

If you can grab specific error messages (from VS’s Output window or NUnit’s logs) when the tests misbehave, that’d help narrow things down even more. But these steps should resolve most of the unpredictable behavior you’re seeing.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 07:58:55