[Pharo-users] The confusing state of SUnit

Tim Mackinnon tim at testit.works
Tue Feb 26 19:14:22 EST 2019

Forgive me father, for I have sinned… but when I try to right good tests, that fail in a way I can understand them it seems that SUnit doesn’t want to help me…

Maybe I am missing something, but in 2019 it should be easy to write tests - particularly when we want people to contribute to adding more?

So when I want to right a test to assure that I’ve thrown an exception with the right message, why is it so hard (in the core image)? Am I missing something obvious?

My example model is supposed to throw a DomainException with a message indicating that the strings :are of different lengths” - I search Sunit and hit:

#should: raise: whoseDescriptionDoesNotInclude: description:

Awesome, so it fails - but does it make it easy to know what damn string I got….. nooooo that would be too easy? Its almost impossible to easily see what happened the way it works.

Instead I have to write:

		should: [ hammingCalculator distanceStrand1: 'AATG' strand2: 'AAA' ]
		raise: DomainError
		withExceptionDo: [ :ex |
			self assert: ex messageText equals: 'left and right strands must be of equal length' ].

And god forbid if I want to just ensure that the beginning of my error message is correct?

Why do we make this so hard? I know we don’t want to pollute the image, but testing is important, it should be easy for obvious cases and it should be more built in and less obscure. Is there something built in that makes this easier? Do I really have to load in more libraries for the easy cases?


More information about the Pharo-users mailing list