[squeak-dev] Porting JUnit's Theories to SUnit?
enrico.spinielli at googlemail.com
Fri Jul 15 19:40:02 UTC 2011
Maybe worth studying is the Assessment framework from
Andres Valloud "A Mentoring Course on Smalltalk"
Just google for
Andres Valloud Assessments
to have an idea.
Hope it inspires
On Mon, Jul 11, 2011 at 16:02, Frank Shearar <frank.shearar at gmail.com> wrote:
> 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.
"Do Androids dream of electric sheep?"— Philip K. Dick
"Hear and forget; see and remember;do and understand."—Mitchel Resnick
More information about the Squeak-dev