Skip to content

Compiling and running tests

Philippe edited this page Sep 24, 2015 · 12 revisions

Test Command

The test command is the main command used when developing with unit tests to updates, compiles and runs all targets within a hxml build file

haxelib run munit test

What it does

  1. Updates active test cases using the gen command
  2. Compiles the targets within the hxml build file
  3. Runs all compiled targets using the run command

By default this command uses the settings from the .munit settings in the project so you don't need to specify anything.

Alternatively you can specify a single target within the build file through a -[platform] flag. Valid options are -swf-neko and -js. If testing both flash 8 and flash 9+ targets you can target one only using -swf8 and -swf9.

haxelib run munit test -swf

To use this command outside a munit project you can also specify manual paths to the hxml, bin, src and report paths you are working with.

Run the inline help for detailed instructions on individual command line options

haxelib run munit help test

Run Command

The run command launches one or more target applications from a specified path

It matches files ending in _test.swf, _test.js and _test.n

haxelib run munit run

By default this command uses the settings defined in the .munit settings in the project so you don't need to specify anything.

How it works

The run command works by launching a nekoserver via localhost to capture http results from flash, javascript and neko targets.

It also launches flash and javascript test applications via your default browser from a localhost url.

It saves junit style generated reports into the report directory on completion.

Browser Settings

By default munit run uses the default browser to launch swf and js targets

To specify an alternate browser use the -browser flag

haxelib run munit test -browser FireFox

To close the browser window after the tests are finished use the -kill-browser flag

haxelib run munit test -kill-browser

Note that this flag only works in browsers which allow javascript to close a browser window. Chrome allows this currently, Firefox does not.

Timeout settings

By default there is a 30s timeout for tests; this duration can be modified using -timeout <seconds> flag:

haxelib run munit test -timeout 60

When specifying a (valid) custom timeout, munit will print out:

Running tests with <custom timeout> seconds timeout.

Known Issues

There are a number of known platform specific issues that may prevent tests from running correctly.

  • Running swf and js tests in Safari
  • "Fatal Error in gc" under Windows 7 (possibly XP too)
  • HTTP POST causes Nekotools server to hang (fixed in 2.1.2)

See Known Issues for more details