BOC

BOC

Micah Martin

November 12, 2006

BOC is a testing pattern that Unclebob briefly mentioned on fitnesse.org shortly after it was published. It describes the typical steps taken in an automated test.

BOC (Build Operate Check) n.: The typical flow of an automated test.

Experienced test writer use BOC whether they know it or not. For new-commers to automated testing, BOC is lesson #1.

If you think about it, BOC is very logical. Every test is testing something; some Operation that the system under test (SUT) performs. That’s where the Operate step comes from.

In almost all cases, you can’t just invoke the operation. The automated test Builds a testable environment first. Maybe data needs to be put in a database, or a service layer needs to be started. Either way, the Build step comes first.

After invoking the Operation, a test needs to Check that it behaved as expected. Clearly, the Check step has to come last.

Example

Consider a test for the Withdraw feature of an ATM machine.

Build

You can’t withdraw money from an account unless there’s money in it. For the build step, add $500.00 to account 123.

Operate

Perform a withdraw of $250.00 from account 123.

Check

Check that the balance of account 123 is $250.00.

Next time you’re writing an automated test, think about it. More likely than not, you’re using BOC.