News |
| SUnit Update |
New Version, New Site, New URL
Not only is there a new version of SUnit out, the web site has been redesigned, and the site has a new URL.
| SUnit 3.1 |
What's new in SUnit 3.1
SUnit 3.1 includes a various bug fixes, as well as a small number of additions and extensions to SUnit. The reason for the release's delay has been the lack of time available to devote to the project, and the problems associated with creating a clean, dialect-independent code base.
SUnit Camp Smalltalk is still available in four parts:- SUnitPreload
- SUnit
- SUnitTests
- SUnitUI
This is a list of the changes made to each module.
SUnitPreload
- the class ResumableTestFailure has been added
- the dialect-specific Error exception has been factored out from TestResult class>>#exError to SUnitNameResolver class>>#errorObject, removing the last dailect dependency from the SUnit core.
- the dialect-specific MessageNotUnderstood exception is available as SUnitNameResolver class>>#mnuExceptionObject
- the dialect-specific Notification exception is available as SUnitNameResolver class>>#notificattionObject
- the dialect-specific default logging device is available as SUnitNameResolver class>>#defaultLogDevice
SUnit Core
The SUnit core package has achieved the goal of having the exact same code for all dialects - almost. The only dialect using a variant code base is Object Studio. Other than that, the changes consist of additions and bug fixes.
Additions
1. Assertion description strings
The TestCase assertion protocol has been extended with a number of methods allowing the assertion to have a description.. These methods take a String as second argument. If the test case fails, this string will be passed along to the exception handler, allowing more variety in messages than "Assertion failed" gives you. Of course, this string can be constructed dynamically.
| e |
e := 42.
self assert: e = 23 description: 'expected 23, got ' e printString
The added methods in TestCase are:
- #assert:description:
- #deny:description:
- #should:description:
- #shouldnt:description:
2. Logging support
The description strings described above may also be logged to a Stream such as the Transcript, a file, stdout etc. You can choose whether to log by overriding TestCase>>#isLogging in your test case class, and choose where to log to by overriding TestCase>>#failureLog.
3. ResumableTestFailure
A resumable TestFailure has been added. What can this be used for? Take a look at this example:
aCollection do: [ :each | self assert: each isFoo]
In this case, as soon as the first element of the collection isn't Foo, the test stops. In most cases, however, we would like to continue, and see both how many elements and which elements aren't Foo. It would also be nice to log this information. You can do this in this way:
aCollection do: [ :each |
self
assert: each isFoo
description: each printString, 'is not Foo'
resumable: true]
This will print out a message to your logging device for each element that fails. It doesn't cumulate failures, i.e., if the assertion fail 10 times in your test method, you'll still only see one failure.
Bug fixes
- Steve Waring found out that when a test that uses TestResources fails and is debugged, the debug process occurs in a separate thread, and the resources are reset in the normal SUnit thread, before the test method can be analysed. The bug was in TestCase>>#debugAsFailure and has been fixed.
- John Brant found that SUnit handles errors that it shouldn't. The bug was in TestCase>>#executeShould:inScopeOf: and has been fixed.
- Alan Knight found that TestCase>>#setUp should be moved inside the #ensure: block, so that #tearDown is also called in the event of an error during test set-up.
- Reinout Heeck pointed out that the default behavior of TestResource class>>#isAvailable should not only check if the resource is not nil, but should also send the resource itself #isAvailable. This has been corrected.
SUnitTests
- the 2 test methods SUnitTest>>#testDebugUI and SUnitTest>>#testFailureDebugUI have been removed.
- Tests for exception handling have been added
- a TestResource test case has been added
- a ResumableTestFailure test case has been added
SUnitUI
- depending on the dialect, there have been minor changes to the TestRunner.
- The TestRunner title bar now shows the version number declared in TestCase class>>#sunitVersion. This eliminates the need to change this package for every new release of the core package.
- Many versions of TestRunner have had a dependency on the SUnitTests package. This dependency has been removed.
- Many versions of TestRunner have presumed that the test failures are an OrderedCollection. This has been corrected.
- The method "TestRunner open" is now standard for opening the TestRunner.