Phexample on Squeak 4.4, 4.5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Phexample on Squeak 4.4, 4.5

Frank Shearar-3
Phexample [1] is a DSL for testing that
(a) provides a bit more of a natural language for testing that
#assert: and friends,
(b) uses the DSL to automatically generate meaningful error messages,
(c) allows you to cleanly reference artifacts from other tests.

So for instance you might write a test

shouldBeAbleToMakeEmptyList
    | l |
    l := #().
    l should not beNil.
    l

Another test can reuse this artifact:

shouldFailWhenRemovingFromEmptyList
    | l |
    l := self given: #shouldBeAbleToMakeEmptyList.
    [l removeLast] should signal: Error

#given: memoises tests, so they don't run more than once.

All kudos goes to Niko Schwarz, Adrian Kuhn and Stefan Marr. Errors in
porting are entirely mine.

(For those interested in the cross-platform nitty gritties, I had to
shim String >> #includesstring:, and import Pharo's Regex-Core
package. But otherwise, it just worked.)

frank

[1] http://smalltalkhub.com/#!/~Phexample/Phexample