UnitTest

Standard unit test class

Writing Unit tests

TestYourClass : UnitTest {

setUp {

// this will be called before each test

}

tearDown {

// this will be called after each test

}

test_yourMethod {

// every method named test_

// will be run

this.assert( 6 == 6, "6 should equal 6");

this.assertEquals( 9, 9 ,"9 should equal 9");

this.assertFloatEquals( 4.0 , 1.0 * 4.0 / 4.0 * 4.0, "floating point math should be close to equal");

// we are inside a Routine, you may wait

1.0.wait;

// this will wait until the server is booted

this.bootServer;

// if the server is already booted it will free all nodes

// and create new allocators, giving you a clean slate

p = Patch({ SinOsc.ar });

p.play;

// will wait until the condition is true

// will be considered a failure after 10 seconds

this.wait( { p.isPlaying },"waiting for patch to play",10);

}

}

UnitTest.runAll

runs all subclasses of UnitTest

YourClass.test

runs the test class for YourClass, which is assumed to be named TestYourClass.

If no test class if found it politely declines.

UnitTests for Common library classes are kept in the CommonTests quark.

This enables you to easily install and uninstall these tests.

note: for the moment gui tests from within UnitTest.runAll will get an error:

ERROR: Primitive '_SCView_New' failed.

operation cannot be called from this Process.

These same tests will work fine if you test the class individually: FlowView.test

A solution is pending.

see also MixedBundleTester, a MixedBundle that saves all of its bundles so that your tests can query what got sent to the Server.