[squeak-dev] The Inbox: SUnit-spd.82.mcz

Bert Freudenberg bert at freudenbergs.de
Fri Oct 1 14:40:56 UTC 2010


On 01.10.2010, at 14:31, commits at source.squeak.org wrote:

> A new version of SUnit was added to project The Inbox:
> http://source.squeak.org/inbox/SUnit-spd.82.mcz

Anyone interested in porting SUnit 4.0?

http://www.squeaksource.com/SUnit.html

In 4.0, SUnit has been refactored.

1) TestResult now double-dispatches via the exception (see #sunitAnnounce:toResult:). This makes it easier for users to plugin specific behaviour.

2) TestResource #setUp and #tearDown is now consistent with TestCase #setUp and #tearDown. TestResource>>setUp is _not_ called by TestResource>>initialize; the framework calls TestResource>>setUp separately. If TestResource>>setUp is entered then a call of TestResource>>tearDown is ensured, just as for TestCase. (TestResource>>uninitialize, introduced in in SUnit 3.2 in an earlier attempt to address this problem, is now deleted.)

IMPORTANT: it has always been the case that TestCase>>tearDown code may require
someVar isNil or: [someVar doTearDownStuff].
guards to handle the possibility that the test fails in early #setUp before someVar has been assigned (the symptom of not having the guard is that the run shows two errors for the same test in that case). The above change to TestResult means that some resource #tearDown code may now also require these guards. These cases are usually very obvious to spot and fix, so we have accepted this side effect of the change.

Otherwise, framework behaviour and API are unaffected by this change. However in the very rare case that a user has written a programmatic script for manipulating TestResources, they would need to replace any
var := MyTestResource new.
with
var := MyTestResource new; setUp.
since #new's call of #initialize no longer calls #setUp.

3) There are changes to #testSelectors, #allTestSelectors, #sunitAllSelectors (which is now deprecated) and #sunitSelectors (which is now in protocol 'private', does not guarantee order, is now trivial to inline and may in future be deprecated). Associated changes to #buildSuiteFromSelectors, with deletion of #buildSuiteFromLocal/AllSelectors, integrate suite building with #shouldInheritSelectors and a new method, #lookupHierarchyRoot, giving more consistent test inheritance behaviour, and better performance in hierarchies with many selectors and fewer test selectors. Any utilities that called #buildSuiteFromLocal/AllSelectors explicitly can eliminate both calls, and the boolean test that decides which call to send, in favour just calling #buildSuiteFromSelectors.

4) In all normal-usage cases, TestResources now ask their requesting test or candidate-resource to signal their failure, thus providing more informative logging.

- Bert -





More information about the Squeak-dev mailing list