Jun 17 2009
Four Phases Test of Unit Testing
Gerald Meszaros has defined four phases to be included while structuring unit tests. The four phases are:
- Setup is the first phase where test fixture is setup for the SUT (System under Test) to exhibit the expected behaviour as well as anything we need to put in place to be able to observe the actual outcome
- Interact with the SUT or exercise
- Verify / Determine if expected outcome is obtained
- Tear Down the test fixture
Implementation
Account.rb
class Account
MIN_BALANCE = 100
attr_reader :balance
def initialize
@balance = MIN_BALANCE
end
end
account_test.rb
class Account_Test < Test::Unit::TestCase
def test_there_should_be_minium_balance_when_account_is_created
#setup
@account = Account.new
#exercise
balance = @account.balance
#verify
assert_operator balance, :>, 0
end
def teardown
@account = nil
end
end
You can get more information about this topic here.

Comments Off



