Smalltalk report

Markus Gaelli gaelli at emergent.de
Mon Aug 14 10:12:07 UTC 2006


On Aug 14, 2006, at 11:13 AM, Klaus D. Witzel wrote:

> On Mon, 14 Aug 2006 10:55:29 +0200, Marcus Denker  
> <denker at iam.unibe.ch> wrote:
>> And have a look at BehaviorTest>>#testChange
>
> This test is a *very* good one, 100% pure[tm] object-oriented :)

I disagree. Whereas the _tested_ stuff is great, we don't know what  
kind of test it is, without reading it. Also - we would not find it  
easily as an example for instance specific behavior.
Certainly this is the way SUnit tests are supposed to look like, but  
who says, that SUnit is the best way (pure[tm] object-oriented) of  
testing?

I'd categorize this test as a "method test" focusing on
	Behavior >> compile: aString
(See our Unit Test Taxonomy Paper below)

I found it more object-oriented, if the test would be explicit about  
what it is showing and looked like:
===============
Behavior class (examples) >> exampleCompileThisIsATest
	"I return a sample behavior of thisIsATest ^2
	So I do not only exemplify an instance of this class, but also of  
compile: aString
	(As there is no annotation a la self test:[], an extended  
OmniBrowser could assume that it is the last method called, which is  
exemplified.)
	Browse for _real senders_ of me, to see me in context"

	|aBehavior|
	aBehavior := self new.
	aBehavior compile: 'thisIsATest  ^ 2'.
	^aBehavior

Model class (examples) >> examplePlugInstanceBehavior
	|aModel|
	aModel := self new.
	self precondition: [self should: [aModel thisIsATest] raise:  
MessageNotUnderstood].
	aBehavior := Behavior exampleCompileThisIsATest.
	aBehavior superclass: self.
	aBehavior setFormat: self format.
	aModel primitiveChangeClassTo: aBehavior new.
	self assert: model thisIsATest = 2.
	^aModel
===============
I think this way
- is more object oriented and you could browse the class side of  
Behavior to see how its instances can be applied
- you could reuse this instance specific behavior in more tests
- shows, that we might miss a single method to plug this instance  
specific behavior as
	aBehavior superclass: self.
	aBehavior setFormat: self format.
	aModel primitiveChangeClassTo: aBehavior new.
  is a bit verbose and could be subsumed into a single "Object >>  
changeClassTo: aBehavior" method. Thus the latter example would  
exemplify this method.

Thanks for this nice example, I think I can reuse it for academic  
purposes... ;-)

Cheers,

Markus

Please find our Test Taxonomy Paper on:
http://www.iam.unibe.ch/~scg/Archive/Papers/ 
Gael05aTowardsATaxonomyOfUnitTests.pdf



>
> /Klaus
>
>> testChange
>> 	"self debug: #testChange"
>>
>> 	| behavior model |
>> 	behavior := Behavior new.
>> 	behavior superclass: Model.
>> 	behavior setFormat: Model format.
>> 	model := Model new.
>> 	model primitiveChangeClassTo: behavior new.
>> 	behavior compile: 'thisIsATest  ^ 2'.
>> 	self assert: model thisIsATest = 2.
>> 	self should: [Model new thisIsATest] raise: MessageNotUnderstood.
>>
>>
>>
>
>
>




More information about the Squeak-dev mailing list