Add a custom task for RoyaleUnit to your Apache Ant build files
First, we need to add a <taskdef>
to make the <royaleunit>
task available for use in our build file:
<taskdef resource="royaleUnitTasks.tasks" classpath="${royalesdk}/js/lib/royaleUnitTasks.jar"/>
Replace the ${royalesdk}
token with the path to the Apache Royale SDK on your computer.
To run unit tests with a web browser and JavaScript, set the player
attribute to "html"
. This tells the Ant task to use the WebSocket protocol. Set the swf
attribute to the path to an .html file:
<royaleunit player="html" swf="${basedir}/bin/js-debug/index.html"/>
In the example above, we point to the index.html file generated by the Apache Royale compiler in bin/js-debug.
By default, the unit tests will run in your computer's default web browser. To run in a specific web browser, you may specify the path to an executable using the command
attribute.
In the following example, we'll run unit tests in Google Chrome.
On Windows, set the command
to an .exe file:
<royaleunit player="html" swf="path/to/file.html" command="c:/Program Files/Google/Chrome/Application/chrome.exe"/>
On macOS, set the command
to the executable inside an .app package:
<royaleunit player="html" swf="${basedir}/bin/js-debug/index.html" command="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"/>
To run unit tests with Adobe Flash Player, set the player
attribute to "flash"
. Set the swf
attribute to the path of a .swf file:
<royaleunit player="flash" swf="bin-debug/ExampleApp.swf"/>
The unit tests will run in your default application associated with .swf files. To run in a specific version of the standalone Adobe Flash Player projector, you may specify the path to the executable using the command
attribute.
On Windows, set the command
to an .exe file:
<royaleunit player="flash" swf="bin-debug/ExampleApp.html" command="path/to/flashplayer_32_sa_debug.exe"/>
On macOS, set the command
to the executable inside an .app package:
<royaleunit player="flash" swf="bin-debug/ExampleApp.html" command="/Applications/Flash Player.app/Contents/MacOS/Flash Player Debugger"/>
To fail the Ant build if the unit tests fail, set the haltonfailure
attribute to true
:
<royaleunit player="html" swf="${basedir}/bin/js-debug/index.html" haltonfailure="true"/>