I recently switched from using make to using ant for my build process. One nice thing about ant is that it has integrated JUnit support, for running tests as part of the build. Not wanting to miss a similar capability, I wrote AOSUnitRunner to do the same thing. Some day (when I'm really feeling masochistic), I might write a Java wrapper for it, so that it can be called as an internal ant task, but for now, it works quite nicely as an exec() task, thank you.
AOSUnitRunner is delivered as a zip file. If all you want to do is use AOSUnitRunner, just yank the AOSUnitRunner.exe out of the zip file and copy it to your SmallScript /packages directory.
AOSUnitRunner is a command-line utility which runs AOSUnit on test case files. You can runit either on a single file, or on a directory containing test case files.
Executing the tool with -? or -h will give you the following help text:
Syntax: AOSUnitRunner [options] mode:path where options are: -? or -h - help (prints this text) -o:outputfile - name of the file to redirect output to -q - quiet mode mode:path is either: -d:dir - path of directory with test case files -f:filename - name of test case file
If you do not specify an output file, the test results will not be emitted. Quiet mode is currently not supported, but is coming RealSoonNow
AOSUnitRunner expects the files it runs to each contain a TestCase subclass with a number of test methods, and an eval block at the end to run the suite. This is standard format for AOSUnit, and is shown below. More extended examples can be found in the .\tests directory of the AOSUnit distribution.
Load module: AOSUnit.
Class name: FooTestCase extends: TestCase {
Method [
testPass
self assert: true
]
Method [
testFail
self assert: false
]
Method [
testError
3 zork
]
}
[
FooTestCase runSuite.
]
AOSUnitRunner -f:myTestCase.sts
will run AOSUnit on myTestCase.sts, and emit the standard AOSUnit output to stdout. No results will be saved to file.
AOSUnitRunner -o:myTestCase.results -f:myTestCase.sts
does the same as above, but stores the result output in the file myTestCase.results.
AOSUnitRunner -o:myTestCase.results -d:myTestCases
will iterate through all the files in the directory myTestCases, running AOSUnit on each one, and storing the results to the file myTestCase.results.
In order to use AOSUnitRunner to automate your testing, it's best to create a testing task in Ant. Since I haven't yet gotten around to writing a Java wrapper for it (which would let you call AOSUnitRunner as an internal task), you need to call the program through an exec() task.
The following examples are the Ant tasks corresponding to the examples above.
<target name="test" description="Run tests">
<exec executable="AOSUnitRunner.exe">
<arg line="-f:myTestCase.sts"/>
</exec>
</target>
will run AOSUnit on myTestCase.sts, and emit the standard AOSUnit output to stdout. No results will be saved to file.
<target name="test" description="Run tests">
<exec executable="AOSUnitRunner.exe">
<arg line="-o:myTestCase.results"/>
<arg line="-f:myTestCase.sts"/>
</exec>
</target>
does the same as above, but stores the result output in the file myTestCase.results.
<target name="test" description="Run tests">
<exec executable="AOSUnitRunner.exe">
<arg line="-o:myTestCase.results"/>
<arg line="-d:myTestCases"/>
</exec>
</target>
will iterate through all the files in the directory myTestCases, running AOSUnit on each one, and storing the results to the file myTestCase.results.
The following example is taken from the build script I use to generate my tools. You'll see that the paths are aliased so that the build script is reuseable for many projects. BTW - the failonerror parameter doesn't seem to work here. Any help would be appreciated.
<target name="test" depends="clean" description="Run tests">
<exec executable="AOSUnitRunner.exe" failonerror="true">
<arg line="-o:${log.dir}\${ant.project.name}.results"/>
<arg line="-d:${test.dir}"/>
</exec>
</target>
This document Copyright © 2002 by Joseph Pelrine and MetaProg GmbH. All rights reserved. SmallScript is a registered trademark of SmallScript LLC. Name and Logo used with permission of David Simmons and SmallScript LLC.