Test Patterns: State vs Behavior Verification

This site gives a good definition of State Verification and Behavior Verification as it concerns our efforts to establish unit tests for all new functionality.

State Verification
Behavior Verification

Heres the one line definition for each if you want the 50,000 foot view.

State Verification: We inspect the state of the system under test (SUT) after it has been exercised and compare it to the expected state.

State Verification

Behavior Verification: We capture the indirect outputs of the SUT as they occur and compare them to the expected behavior.

Behavior Verification

Its a subtle but important distinction in that with state verification you may run a series of method call or processes and verify the expected state of the system after all the call have been made. With behavior verification you are interested in verifying that individual method calls are made to components within the system under test including dependent components utilized by the system under test.

Mock Objects

Nice intro to using Mock Objects in .NET – provides some discussion on the two main mock frameworks in addition to an overview and a general idea of why and how to use this useful libraries.

The article is here

Scott has a follow up article on mocks (Mocks – It’s a Question of When) discussing when you would choose to use mocking, which is here


Martin Fowler has an article about the art and science of mocking, called “Mocks Aren’t Stubs” that is also well worth reading.