Pharo programming culture adheres to agile programming
In a test, we
TestCase subclass: # SetTestCase
...
SetTestCase >> testAdd
| empty |
empty := Set new. "Context"
empty add: 5. "Stimulus"
empty add: 5.
self assert: empty size = 1. "Check"
SetTestCase run: #testAdd
Each method starting with test*
:
The results of the test are collected in a TestResult
object
testAdjacentRunsWithEqualsAttributesAreMerged
"this demonstrates that adjancent runs with equal attributes are merged. "
| runArray |
runArray := RunArray new.
runArray
addLast: TextEmphasis normal times: 5;
addLast: TextEmphasis bold times: 5;
addLast: TextEmphasis bold times: 5.
self assert: (runArray runs size = 2).
SetTestCase >> removeElementNotInSet
self
should: [ Set new remove: 1 ]
raise: NotFound
SetTestCase >> removeElementNotInSet
self
shouldnt: [ Set new add: 1 ]
raise: NotFound
SetTestCase >> testOccurrences
| empty |
empty := Set new.
self
assert: (empty occurrencesOf: 0)
equals: 0.
empty add: 5; add: 5.
self
assert: (empty occurrencesOf: 5)
equals: 1
empty := Set new.
is repeated between testssetUp
allows us to specify and reuse the contexttearDown
to clean after
SetTestCase >> setUp
empty := Set new
setUp
is executed for you before any test execution
SetTestCase >> testOccurrences
self
assert: (empty occurrencesOf: 0)
equals: 0.
empty add: 5; add: 5.
self
assert: (empty occurrencesOf: 5)
equals: 1
TestCase
represents one testSetTestCase >> testOccurenceOf
TestSuite
is a group of tests'test*'
TestResult
represents a test execution resultsTestResource
is an object which is needed by a number of Test Cases, and whose instantiation is so costly in terms of time or resources that it becomes advantageous to only initialize it once for a Test Suite run.TestResource
is invoked once before any test is run. (read Pharo by Example SUnit Chapter)setUp
methods/