PackageDescription: SUnitResourcePatterns

S Unit Resource Patterns

Last published: July 24, 2015 by 'nross'

Defines 10 Classes
Extends 14 Classes

Normal use of SUnit involves much subclassing of TestCase, leaving the other concrete classes of the framework alone. This utility contains examples of subclassing TestSuite, TestResult, TestFailure and TestResource. The following is a summary: see each subclass' comments for details.

If RBSUnitShowResult is loaded, you can use the Tools > Testing page of the VisualLauncher settings to set suite and result classes for the image. If not (or instead), execute
XProgramming.SUnit.TestCase suiteClass:
to use a TestSuite subclass and
XProgramming.SUnit.TestCase suiteClass:
( resultClass: )
to use a TestResult subclass. To revert, execute
XProgramming.SUnit.TestCase suiteClass: XProgramming.SUnit.TestSuite.

TestSuite subclasses include:
MinimalResConflictSuite: pessimistic handling of possible resource conflicts (only OK if shared in class)
PackageResConflictSuite: less pessimistic handling of possible resource conflicts (OK if shared in package)
RandomSuite: run the tests in a random order
FastSuite: only raise #changed notifications when a given time has elapsed

TestResults subclasses include:
ClassifiedTestResult: classify results against any tag, not just pass/fail/error
KeepLatestResult: (in RBSUnitShowResult) classify results against any tag, not just pass/fail/error

TestFailure subclass: TestSkip is used by skipUnless:{description:}, skipIf:{description:} or (variant form) #assert:orSkip:, #deny:orSkip: to replace TestCase or TestResource code of the form:
self platform isMac ifFalse: [^self].
"This test only makes sense on Mac OS"
self skipUnless: self isOnMac
description: 'This test only makes sense on Mac OS'.
When running a suite containing tests with this protocol, standard practice is to use the subclassing pattern above to ensure the test result is a ClassifiedResult (or subclass or compatible class). However calling #addSkip: on a TestResult transforms it into a ClassifiedResult, to which further skips or other specialised results may be added (but this uses #become:, hence the preference for anticipating the need by plugging in the result subclass).

TestResource subclasses:

- InvariantResource: when you want a run to leave the resource active if and only if it was active before the run started.

- CompetingResource: when two (or more) resources cannot both be available at the same time but you wish to run tests using both in an optimistic suite.