[squeak-dev] Re: Porting JUnit's Theories to SUnit? (Frank Shearar)
rpboland at gmail.com
Tue Jul 12 14:46:52 UTC 2011
> Has anyone looked into porting JUnit 4's Theories into SUnit? (NUnit
> also uses theories, in 2.5)
> In brief, a Theory is a test that takes a parameter. So what before might say
> -1 to: 1 do: [:i | self assert: i myFoo = i printString
> description: 'Failure for integer ', i printString]
> testMyFooPrintsIntegersHomoiconically: anInteger
> self assert: anInteger myFoo = anInteger printString description:
> 'Failure for integer ', anInteger printString
> You define a bunch of DataPoints, and then the runner runs that test
> for every data point. In JUnit data points are defined through
> constants with @DataPoint/@DataPoints annotations, but of course we
> can do them however we want. Further, theories can make assumptions,
> which are essentially pretest filters. For instance, in a TestCase
> dealing with real algebra, a test for square roots might say
> testSquareRootReturnsRoot: anInteger
> self assumeThat: [anInteger > 0].
> "Rest of test"
< and then the test would only run on positive data points.
> The essential idea is simply decoupling the test itself - the theory -
> from the data, so you don't have to roll your own looping construct
> when testing multiple data points.
I am developing an extension to SUnit that allows a single TestCase to
run a large number
of tests (the tests are generated using combinatorial generation).
If a failed TestCase is evaluated it restarts at the first failing
test and avoids starting
from the first test. This is done using signal handling and my own version of
You can also these tests using a GUI called RunnRunner which allows you to set
parameters such as the number of tests to generate/run.
RunnRunner is meant to be used during development.
When this code is complete I will release it as open source to Squeak/Pharo.
This release is many man-months of work away.
I will also eventually be adding GUIs called ExampleRunner,
(for measuring performance/ making comparisions between
and perhaps even DocumentRunner (for accessing external documentation).
The church wants your soul.
The communists want your mind.
The capitalists only want your money (OK, all your money).
More information about the Squeak-dev