Test units¶
OVERVIEW¶
First, the easiest part is that in the Jamoma/Tools folder there is a 'test.sh' script. This is a shortcut for running the Ruby stuff in that Tests submodule.
Second, there is the Test submodule which includes the appropriate machinery.
Third, there are tests. These tests are potentially spread out all over the place in different submodules. For example, in "Jamoma/Modules/Modular/Tests". What designates a test is not its location, but rather the fact that it ends in ".test.maxpat".
RUNNING TESTS¶
In theory, you should be able to cd in the Terminal to the Tools folder and run
./test.sh
In reality, I may have forgotten some steps, so let me know if there are problems*.
This should go through each test patcher, one at time, opening them and closing them when they are done. If something goes wrong, it should be reported as a failed assertion. If something serious is wrong (or wrong with the test), it could just hang on a test and never close it -- but be patient, some tests take quite a bit of time to complete. If something catastrophic is wrong, then Max will crash -- but the output of the ruby script should tell you which test crashed.
Some example output looks like this:
/code/Jamoma/Modules/AudioGraph/Tests/externals.loading.test.maxpat: MaxError:error newobj: out≈: No such object MaxError:error newobj: oscil≈: No such object MaxError:error newobj: op≈: No such object MaxError:error newobj: noise≈: No such object MaxError:error newobj: info≈: No such object MaxError:error newobj: in≈: No such object MaxError:error newobj: gain≈: No such object MaxError:error newobj: filter≈: No such object MaxError:error newobj: dcblocker≈: No such object MaxError:error newobj: dac≈: No such object FAILED: TEST Multicore AllExternalsLoadingProperly ******************** (externals.loading.test.maxpat completed in 1.000552 seconds)
This test failed, and you can see why. The test is not up to date and is trying to load externs with the old names. Here is another tests' output:
/code/Jamoma/Installers/temp/Applications/Max5/Cycling '74/Jamoma/modules/control/_template/jmod._template.test.maxpat: PASSED: correctGainConversionDb PASSED: NoMaxErrors (jmod._template.test.maxpat completed in 1.000549 seconds)
This one passed. Hooray!
ANATOMY OF A TEST¶
When you just run the tests, a bunch of things are automated. Some stuff gets added to the searchpath automatically, etc. When you want to develop tests yourself, you'll need to add this stuff to your searchpath. This means adding the stuff in the Modules/Test folder to the searchpath. Then you can edit and write your own test patchers.
A good place to start is @ Jamoma/Modules/Modular/Tests/jcom.pi.test.maxpat -- this test very simple:
- A loadbang starts the test
- Some operation is performed, the results of which go to an object [test.assert.equal TESTpi 3.141593] -- the first arg is the name of the assertion, the second arg is the value that must be true in order to pass the test.
- A bang goes to the [test.finished] object
Note: to open this patcher for editing, you will want to defeat the loadbang before opening it (open it while holding down the command-shift key combo).
Any given test may have multiple assertions, which you'll see by looking at a few tests.
(Tim, may 2010)
- There is a problem with Ruby 1.9. You need to modify the 'test.sh' script. Change this line:
ruby testrunner.rb . default ../..to this:/usr/bin/ruby testrunner.rb . default ../..