Hi list! Imagine you want to test the Stack class, and your first test just creates a test and checks if it's empty.
Then in your second test, you create the same empty stack, but now push an element 'apple' and check if the size is one. Then in your third test, you do all the same, and then you pop the element and check that it is an apple. Wouldn't it be great if you could write your test cases such that they could expand on one another? If you didn't need to copy paste the code of the previous test and just say that you require the previous one! Well, that's what PhExample lets you do. And as a bonus, tests are ignored if the test they expand on does not pass. This gives you less failed tests, because examples are executed only if the examples they expand on pass too! That gives you the simplest failing examples in your set to look at! And best of all, you can run all examples with ye old TestRunner! The example discussed above would read in code as follows: EGExample subclass: #ForExampleStack … shouldBeEmpty "Create the empty stack" | stack | stack := Stack new. stack should be isEmpty. stack size should = 0. ^ stack shouldPushElement "Push one element" | stack | stack := self given: #shouldBeEmpty. stack push: 42. stack should not be isEmpty. stack size should = 1. stack top should = 42. ^ stack shouldPopElement "And pop it again" | stack | stack := self given: #shouldPushElement. stack pop should = 42. stack should be isEmpty. stack size should = 0. Find the code at http://www.squeaksource.com/PhExample.html. The repository is write-global, so feel free to drop your ideas! PhExample is based on JExample by Lea Haensenberger, Adrian Kuhn, and Markus Gaelli. See http://scg.unibe.ch/research/jexample. _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project