Anyway, he showed how the test runner was now parameterized as an
annotation allowing Flex Unit 4 suites to run unit tests based on
*any* unit testing framework (very cool). That's also how Flash
Builder integrates with Flex Unit 4 - it uses a runner that opens a
socket connection to Flash Builder itself to communicate results.
The other thing he showed blew me away: theories!
These are parameterized test methods which the framework runs for all
combinations of data points provided. E.g., if you mark a test method
as @Theory and it takes two numeric arguments, and you provide an
array of 0 .. 9 as one the @DataPoint values, the framework runs the
method for (0,0), (0,1), (0,2) .. (1,0), (1,1), (1,2) .. (9,7), (9,8),
(9,9) - all 100 possible combinations.
In Flex Unit 4, it pulls together all the @DataPoint objects it finds
and aggregates them by type (including calling methods marked as
@DataPoint to dynamically retrieve more test values). Then, when it
hits a @Theory, it introspects the types of the arguments and then
iterates over the method for all combinations of data points that
matches the types of the arguments to the theory.
This can dramatically reduce the number of test cases you have to
write to achieve coverage in many situations as well as improve code
coverage beyond anything you would other manually write.
I'd love to see something like this added to MXUnit!
Case in point, I've just written 16 test cases (that actually test 28
assertions) and I could have cut this down to just two test cases if
I'd had theories!
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
That's pretty close... now if you could do this as well:
<cffunction name="testSomething">
<cfargument name="q" mxunit:dataprovider="queryName"/>
<cfargument name="id" mxunit:dataprovider="userIdList"/>
...
</cffunction>
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/