[squeak-dev] Porting GNU Smalltalk code to Squeak

Frank Shearar frank.shearar at gmail.com
Mon Aug 8 09:42:12 UTC 2011

On 8 August 2011 00:11, Andrew Pennebaker <andrew.pennebaker at gmail.com> wrote:
> SUnit is so integral that it's built into the Smalltalk package manager. But
> it's a bit redundant to use one unit testing framework's methods in another,
> no? Also, the current output format tries to match QuickCheck's as closely
> as possible.
> I've used JUnit before, but I'm not sure what "Data and Theory" refer to.

It's a few things: a custom test runner, a data generator, and a
specially annotated test (the Theory). The test runner runs the
specially annotated test repeatedly against the data generator. A
theory may also use Assumptions, which basically filter out some data.
For instance,

public class UserTest {
  @DataPoint public static String GOOD_USERNAME = "optimus";
  @DataPoint public static String USERNAME_WITH_SLASH = "optimus/prime";

  @Theory public void filenameIncludesUsername(String username) {
    assumeThat(username, not(containsString("/")));
    assertThat(new User(username).configFileName(), containsString(username));

http://junit.sourceforge.net/doc/ReleaseNotes4.4.html has the full details

My thoughts here are
* extend SUnit to support theories
* plug QuickSmash into SUnit via the data generator stuff for the theories

> QuickCheck likes to test functions. It works really well in Haskell, even
> figuring out how to generate the variables to send to the function.
> For more information see the Introduction to QuickCheck article.
> http://www.haskell.org/haskellwiki/Introduction_to_QuickCheck

Yes, that's the _really_ interesting part about QuickCheck - that you
don't have to set up the data generators yourself; it can use the type
signature of your function to figure all that out automatically.
Without type annotations of some kind, or using a type inference
engine (like Chuck, or RoelTyper), that's not going to happen without
a LOT of work.


> Cheers,
> Andrew Pennebaker
> www.yellosoft.us
> On Sun, Aug 7, 2011 at 5:47 PM, Frank Shearar <frank.shearar at gmail.com>
> wrote:
>> On 7 August 2011 21:19, Andrew Pennebaker <andrew.pennebaker at gmail.com>
>> wrote:
>> > Can someone help me make QuickSmash Squeak-friendly? It's a unit test
>> > framework based on QuickCheck.
>> > QuickSmash
>> > https://github.com/mcandre/quicksmash
>> Ah, you gave up and wrote your own port of cl-quickcheck, then [1]?
>> If I understand QuickCheck correctly, it's two things:
>> * assertions / specifications describing correct behaviour;
>> * a combinator library of random data generators.
>> The first could probably use SUnit's assert: and friends (which
>> definitely need some helper methods - I re-implement an
>> #assert:equals:description in every library I write, just about).
>> The second will probably need no more help than an easy way to port
>> gst code to Smalltalk. I'll try and experiment with Coral (which uses
>> a suspiciously gst-like syntax for its scripts) and see if I can't
>> hack something up.
>> TestRunner needs some updating imo: I'd like to see JUnit's Theory
>> stuff, into which QuickSmash would trivially plug in: with the caveat
>> that I may have missed the point, QuickSmash sounds to me just like
>> the Data part of the Theory stuff. (And when we find a failing test
>> case, we report the case and store the continuation of the test case
>> allowing an interactive debugging session on the problem! Yay!)
>> frank
>> [1] http://stackoverflow.com/questions/6962084/quickcheck-for-smalltalk

More information about the Squeak-dev mailing list