[GOODIE] TestMaker

danielv at netvision.net.il danielv at netvision.net.il
Sat Dec 22 00:09:41 UTC 2001


Cool, glad you like it. A couple of things that might help -

Your tests classes need to be subclasses of TestCase - that's how SUnit
works. #deny: for example, is defined by TestCase, and you need to
inherit it for test method to work.
TestCase also defines #should:, which accepts a block.

> testMPEGPlayerPlayFileChimpMpg
> 	self deny: ([| foo | 
> 		foo _ MPEGPlayer playFile: 'chimp.mpg'.
> 		foo playStream: 0] value) = a MPEGPlayer
> 
> A second syntax error is caused by your "= a MPEGPlayer". I'm not sure how
> that is supposed to work ?

Yes, that's too complicated for this code. The hack assumes that
whatever gets returned by the expression, is wrong. It put the result's
printString on the right side of the comparison, which works for some
objects, but definitely not all. To get a more sophisticated test, you
need to specify what does your snippet does, and what's wrong with it,
and make the test check for that.

If you make a subclass of TestCase, its test* methods will appear in
TestRunner.

Daniel

Simon Michael <simon at joyful.com> wrote:
> Hi Daniel,
> 
> great idea I think. I tried it on the last thing which failed for me, an
> attempt to play an mpeg:
> 
> | foo |
> foo _ MPEGPlayer playFile: 'chimp.mpg'.
> foo playStream: 0.
> 
> I got over one syntax error by wrapping this in "[...] value", so the test
> method looks like:
> 
> testMPEGPlayerPlayFileChimpMpg
> 	self deny: ([| foo | 
> 		foo _ MPEGPlayer playFile: 'chimp.mpg'.
> 		foo playStream: 0] value) = a MPEGPlayer
> 
> A second syntax error is caused by your "= a MPEGPlayer". I'm not sure how
> that is supposed to work ?
> 
> I wasn't sure what class to add this to so I just said MPEGPlayer.
> Perhaps this is why the new test didn't show up in a TestRunner.
> 
> Best regards,
> -Simon




More information about the Squeak-dev mailing list