Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 1.77 KB

rule.adoc

File metadata and controls

53 lines (42 loc) · 1.77 KB

It is very easy to write incomplete assertions when using some test frameworks. This rule enforces complete assertions in the following cases:

In such cases, what is intended to be a test doesn’t actually verify anything.

Noncompliant Code Example

string actual = "Hello World!";
// MSTest
StringAssert.That;   // Noncompliant
// Fluent Assertions
actual.Should();     // Noncompliant
// NFluent
Check.That(actual);  // Noncompliant
// NSubstitute
command.Received();  // Noncompliant

Compliant Solution

string actual = "Hello World!";
// MSTest
StringAssert.That.Contains(actual, "Hello");
// Fluent Assertions
actual.Should().Contain("Hello");
// NFluent
Check.That(actual).Contains("Hello");
// NSubstitute
command.Received().Execute();

Implementation Specification

(visible only on this page)


(visible only on this page)