. .


Test Reporting with SUnitToo

April 11, 2011 14:40:57.589


What I wanted was a simple configuration object - it would hold a collection of TestCase class names, in a specific order. Those classes have a class method, #order which specifies the order for the tests in the class. If the method is absent, then I just query the class for all test methods and use the order that comes back. Actually running tests is pretty easy, and there's a nice class - Results - already there to gather results for you:


tests do: [:eachTest |
		| tc |
		tc := aTestCaseClass selector: eachTest.
		self orderRun add: eachTest.
		tc run]


To get the results saved, all you do is something like this:


Results collectWhile: [self runTestsInOrder].


You end up with a nice set of passed, failed, and errored out tests, which you can then easily report on. I created a simple little reporter object that dropped out three html tables, each wrapped in a named div (so that someone with some CSS awareness could do something useful with the results). It all came together pretty quickly. Next up: creating a simple UI to create the test configurations.

posted by James Robertson

 Share Tweet This