Primitive Assertion

Definition:

  • Assertions that use primitive content to express intent

Code Example:

@Test
public void testMethod() {
    MyClass obj = new MyClass();
    int expected = 5;
    int actual = obj.doSomething();
    assertThat("Result of doSomething() should be greater than expected",
            actual, greaterThan(expected));
}

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring