The Silent Catcher

Definition:

  • A test that passes if an exception is thrown. Even if the exception that actually occurs is one that is different than the one the developer intended.

Also Known As:

  • The Secret Catcher

Code Example:

[Test]
[ExpectedException(typeof(Exception))]
public void ItShouldThrowDivideByZeroException()
{
  // some code that throws another exception yet passes the test
}

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring