A test method calls no assertion, so it passes as long as nothing throws
What it finds
A test that never asserts checks only that the code does not throw, which is rarely all that was meant. The rule looks for calls whose name or receiver mentions Assert, Should, Verify, Expect, Throws, Check or Fail, and for throw, anywhere in the test; helpers called from the test that assert are not followed, so tests delegating to them can be suppressed.
From the rule's source, test_without_assertion.rs.
using Xunit; public class Orders{ [Fact] public void Creates()tx0 reports: the test Creates asserts nothing { var order = new object(); order.ToString(); } [Fact] public void Counts() { Assert.Equal(1, 1); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:test-without-assertion" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:test-without-assertion] reason="..."tx0 explain tx0/csharp:test-without-assertion shows the same in the terminal. Found a false positive? Report it.