![]() |
Articles Feed |
Categories
Archives
- July 2010 (5)
- June 2010 (4)
- April 2010 (3)
- March 2010 (2)
- February 2010 (2)
- January 2010 (1)
- December 2009 (1)
- October 2009 (2)
- September 2009 (2)
- August 2009 (1)
- July 2009 (5)
- June 2009 (2)
- May 2009 (2)
- April 2009 (8)
- March 2009 (7)
- January 2009 (2)
- December 2008 (3)
- November 2008 (5)
- October 2008 (4)
- September 2008 (6)
- August 2008 (4)
- July 2008 (5)
- June 2008 (5)
- May 2008 (4)
- April 2008 (2)
- February 2008 (4)
- January 2008 (2)
- December 2007 (2)
- November 2007 (2)
- October 2007 (2)
- September 2007 (1)
- August 2007 (3)
- July 2007 (1)
- June 2007 (4)
- May 2007 (7)
- April 2007 (2)
- February 2007 (3)
- January 2007 (3)
- November 2006 (3)
- October 2006 (3)
- September 2006 (17)
- November 2004 (1)
BOC
by: micah | November 12th, 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.
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.

October 18th, 2008 at 06:32 PM BDD is based on a similar triad - basically the same, but with different names: Given, When, Then. The nice thing about that is that customers and developers can talk about it and it means the same thing: Given an account with 500 bucks When you withdraw 250 Then there should still be 250 It's almost exactly the same, just possibly more customer friendly lingo.