The Inbox: SUnit-spd.82.mcz

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

The Inbox: SUnit-spd.82.mcz

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

==================== Summary ====================

Name: SUnit-spd.82
Author: spd
Time: 1 October 2010, 10:31:26.892 am
UUID: 6332b14d-4ac9-4fdb-bffb-8e225050f415
Ancestors: SUnit-nice.81

* TestCase now uses class>>suiteClass instead of referencing the class name directly
* TestSuite now uses #resultClass instead of referencing the class name directly
* merged 'Accessing' protocol into 'accessing'

=============== Diff against SUnit-nice.81 ===============

Item was changed:
  ----- Method: TestCase class>>buildSuite (in category 'building suites') -----
  buildSuite
  | suite |
+ suite := self suiteClass new.
- suite := TestSuite new.
  ^ self isAbstract
  ifTrue: [
  suite name: self name asString.
  self allSubclasses
  do: [:each | each isAbstract
  ifFalse: [each addToSuiteFromSelectors: suite]].
  suite]
  ifFalse: [self addToSuiteFromSelectors: suite]!

Item was changed:
  ----- Method: TestCase class>>buildSuiteFromMethods: (in category 'building suites') -----
  buildSuiteFromMethods: testMethods
  | suite |
+ suite := (self suiteClass new)
- suite := (TestSuite new)
  name: self name asString;
  yourself.
  ^self addToSuite: suite fromMethods: testMethods!

Item was changed:
+ ----- Method: TestSuite>>resources (in category 'accessing') -----
- ----- Method: TestSuite>>resources (in category 'Accessing') -----
  resources
  ^ resources ifNil: [resources := self defaultResources]
  !

Item was added:
+ ----- Method: TestSuite>>resultClass (in category 'private') -----
+ resultClass
+
+ ^ TestResult.!

Item was changed:
  ----- Method: TestSuite>>run (in category 'running') -----
  run
  | result |
+   result := self resultClass new.
-   result := TestResult new.
  self resources do: [ :res |
  res isAvailable ifFalse: [^res signalInitializationError]].
  [self run: result] ensure: [self resources do: [:each | each reset]].
  ^result
  !

Item was changed:
+ ----- Method: TestSuite>>tests (in category 'accessing') -----
- ----- Method: TestSuite>>tests (in category 'Accessing') -----
  tests
  ^ tests ifNil: [tests := OrderedCollection new]
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: SUnit-spd.82.mcz

Bert Freudenberg

On 01.10.2010, at 14:31, [hidden email] 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 -