Skip to content

Generating Test Classes

misprintt edited this page Nov 21, 2011 · 3 revisions

1. Generating stub test classes

The create command is used to generate a stub test class (and stub target classes if they don't already exist

For example:

haxelib run munit create com.FooTest
haxelib run munit create -for com.Foo
haxelib run munit create com.FooBarTest -for com.Foo

Note: This is only available from version 0.9.2.0

2. Generating the main test runner classes

The gen command is used to create and update the test runner classes.

The 'gen' task is used to create and update the test runner classes. The first time this command runs it will generate a TestMain, TestSuite and ExampleTest class in the test src directory provided. On subsequent runs it will only update the TestSuite with all the test files in the src directory so not to overwrite any customisation in TestMain or test.hxml build file.

All test classes must follow the following naming convention to be included in the generated TestSuite: **Test.hx * (e.g. ExampleTest.hx)

Refer to the generated TestExample for sync and async test usage.

To run this command:

From inside your project directory...

haxelib run munit gen

For detailed help run

haxelib run munit help gen

Filtering a subset of test classes

By default the gen task adds all test classes within the src directory to the TestSuite.hx

To only compile a specific class or package use the filter option

-filter [String]

For example

haxelib run munit gen -filter ExampleTest
haxelib run munit gen -filter com.example.ExampleTest
haxelib run munit gen -filter com.example

Note: This is only available from version 0.9.1.0