NUnit 在汇编中找不到测试

发布于 2024-07-14 05:23:53 字数 179 浏览 6 评论 0原文

我用 MSTest 继承了一个程序集,但这些测试是在构建机器上使用 nunit-console 运行的(不确定它是如何工作的)。 所以我决定对其进行整理并将其更改为适当的 NUnit 测试,但现在 nunit-console (或 gui)找不到任何测试。 不过,使用 ReSharper 测试运行器它们运行得很好。 知道可能缺少什么吗?

I inherited an assembly with MSTest, but these tests were run using nunit-console on the build machine (not sure how it worked). So I decided to sort it out and change them to proper NUnit tests, but now nunit-console (or gui) can't find any tests. They run just fine using ReSharper test runner though. Any idea what could be missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫瑟鸿黎 2024-07-21 05:23:53

检查:

  • 课程是公开的吗?
  • 它是否有一个公共无参数构造函数(例如,如果您不指定任何其他构造函数,则为默认构造函数)
  • 它是否在类级别具有 [TestFixture] 属性?
  • 每个测试都是公开的吗?
  • 每个测试是否都有 [Test] 属性?
  • 每个测试都是无参数的吗?

我相信 NUnit 的某些版本能够根据名称找到测试,例如没有 [Test] 属性的 TestFooBarBaz() ,但我不知道现在的情况如何——但这可以解释这种差异。

Check:

  • Is the class public?
  • Does it have a public parameterless constructor (e.g. the default one if you don't specify any other constructors)
  • Does it have the [TestFixture] attribute at the class level?
  • Is each test public?
  • Does each test have the [Test] attribute?
  • Is each test parameterless?

I believe some versions of NUnit were able to find tests based on their names, e.g. TestFooBarBaz() without the [Test] attribute, but I don't know what the state of this is now - it could explain the discrepancy though.

萌面超妹 2024-07-21 05:23:53

谢谢大家的帮助。 升级到最新的 NUnit 框架解决了这个问题(您建议的所有明显的事情都可以)。

Frederik Gheysels,我想你也可以尝试一下。

Thanks for help, everyone. Upgrading to the latest NUnit framework fixed the problem (all the obvious things you suggested were OK).

Frederik Gheysels, you can try that as well I guess.

乞讨 2024-07-21 05:23:53

您的测试装置、类和方法是公开的吗? 它们必须是 NUnit 才能找到的。

Are your test fixtures, classes and methods, public? They have to be for NUnit to find them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文