rspec/rules/S2187/csharp/rule.adoc

44 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-06-30 12:48:07 +02:00
There's no point in having a test class without any test methods.This could lead a maintainer to assume a class is covered by tests even though it is not.
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
Supported test frameworks are ``++NUnit++`` and ``++MSTest++`` (not applicable to ``++xUnit++``).
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:07 +02:00
This rule will raise an issue when any of these conditions are met:
2021-01-27 13:42:22 +01:00
* For *NUnit*, a class is marked with ``++TestFixture++`` but does not contain any method marked with ``++Test++``, ``++TestCase++``, ``++TestCaseSource++`` or ``++Theory++``.
* For *MSTest*, a class is marked with ``++TestClass++`` but does not contain any method marked with ``++TestMethod++`` or ``++DataTestMethod++``.
2020-06-30 12:48:07 +02:00
== Noncompliant Code Example
----
[TestFixture]
public class SomeClassTest { } // Noncompliant - no test
[TestClass]
public class SomeOtherClassTest { } // Noncompliant - no test
----
== Compliant Solution
----
[TestFixture]
public class SomeClassTest
{
[Test]
public void SomeMethodShouldReturnTrue() { }
}
[TestClass]
public class SomeOtherClassTest
{
[TestMethod]
public void SomeMethodShouldReturnTrue() { }
}
----
== Exceptions
* abstract classes
* derived classes that inherit from a base class that does have test methods
2021-01-27 13:42:22 +01:00
* in *MSTest*, classes that contain methods marked with either ``++AssemblyInitialize++`` or ``++AssemblyCleanup++``.