Pattern: Expected Result

Intent

Ensure that a function with a given arguments returns the expected result or changes the state of object into expected state.

Also Known As

Motivation

Applicability

Use Expected Result to:

Example

In the following test we will check that creates a correct instance of :

public void testAccountManagerCreatesGoodAccount() throws Exception {
    Account account = accountManager.createAccount("testAccount");
    assertNotNull("Null created account", account);
    assertEquals("Wrong created account name", account.getName());
}

References