[squeak-dev] Writing fast tests for things that call #future:

Frank Shearar frank.shearar at gmail.com
Wed Jun 5 11:49:30 UTC 2013


Now that we have a #future: send in PluggableListMorph >>
#changeModelSelection:, we have a number of tests that fail because we
check the state of such a list too quickly. For instance,
MorphicToolBuilderTest >> #testSetListIndex says

testSetListIndex
    self makeList.
    queries := IdentitySet new.
    self changeListWidget.
    self assert: (queries includes: #setListIndex).

and the #assert: happens long before the future triggers.

Now a completely stupid way of "fixing" this would be to add a Delay
after the call to #changeListWidget. That would also smash the test
run times, which are bad enough already.

How can we write tests that run at full speed? One possible way might
be to use a new SUnitProject whose #future:do:at:args: and
#future:send:at:args: immediately trigger the #future: instead of
delaying. That sound like it might bring its own problems.

Other suggestions?

frank


More information about the Squeak-dev mailing list