NUnit doesn't find tests in assembly

2019-02-19 04:36发布

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?

标签: c# nunit mstest
3条回答
霸刀☆藐视天下
2楼-- · 2019-02-19 04:47

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.

查看更多
▲ chillily
3楼-- · 2019-02-19 05:02

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.

查看更多
\"骚年 ilove
4楼-- · 2019-02-19 05:10

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

查看更多
登录 后发表回答