A test case without assertions ensures only that no exceptions are thrown. Beyond basic runnability, it ensures nothing about the behavior of the code under test.


This rule raises an exception when no assertions from any of the following frameworks are found in a test:

* `MSTest`
* `NUnit`
* `xUnit`
* `FluentAssertions` (4.x and 5.x)
* `NFluent`
* `NSubstitute`
* `Shoudly`

== Noncompliant Code Example

[source,csharp]
----
[TestMethod]
public void MyMethod_WhenSomething_ExpectsSomething()
{
    var myClass = new Class();
    var result = myClass.GetFoo();
}
----

== Compliant Solution

[source,csharp]
----
[TestMethod]
public void MyMethod_WhenSomething_ExpectsSomething()
{
    var myClass = new Class();
    var result = myClass.GetFoo();
    Assert.IsTrue(result);
}
----

== Exceptions

To create a custom assertion method declare an attribute with name ``++AssertionMethodAttribute++`` and mark the method with it:


----
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class CustomTest
{
    [TestMethod]
    public void TestMethod1() => Validator.CustomMethod(42);    // Compliant
}

public static class Validator
{
    [AssertionMethod]
    public static void CustomMethod(int value) { }
}

public class AssertionMethodAttribute : Attribute { }
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::../message.adoc[]

'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
