I would like to instrument SUnit tests in Pharo. What is the proper way to change how tests are run?
I want to introduce a timeout to tests, each test I run should be aborted after a given delay.
SUnit does not feature a dedicated TestRunner
in the model that would allow me to introduce changes easily. I can create a new subclass of TestResult
and use the API there (runCase:
, addError:
...) to get the enough control. However it feels strange to change the result class to modify the behavior on how tests are run.
I am used to SMark where I have a dedicated runner to modify these things.
(DISCLAIMER: I do not know what version of SUnit Pharo uses, so the concrete API may differ. Still, I hope this helps a bit.)
Subclassing TestResult
is the way to go even though it may sound bit weird.
The general idea for customizing a new 'SUnit' instance is:
TestResult
(namely #runCase: aTestCase debugged: aBoolean
)TestCase
(namely #performTest
)I personally want to keep SUnit as simple as possible and here I see no reason for introducing a new class. Why? Look to recent changes in JUnit. :-) I do agree that SUnit deserves more documentation.
For examples how to implement timeout, skipping, etc., have a look at TestReport in Smalltalk/X.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With