Skip to content
Philippe edited this page Apr 18, 2018 · 33 revisions

Welcome to the MassiveUnit wiki!

Quick Start Guide

Prerequisites: You'll need to have Haxe installed with Neko.

For instructions for targeting Haxe 3 RC - please refer to https://github.com/massiveinteractive/MassiveUnit/wiki/Migrating-to-Haxe-3

Installation

Run the following commands to install munit, configure it for a project and then run some example tests for all supported platforms.

> haxelib install munit
> mkdir ExampleProject
> cd ExampleProject
> haxelib run munit config
> haxelib run munit test

And if you'd like to test say, just the JavaScript and ActionScript 3.0 targets

> haxelib run munit test -js -as3

munit alias

A useful tip is to add a shortcut for munit to you terminal or cmd prompt to save you typing haxelib run munit .. each time. On OSX add an alias:

alias munit="haxelib run munit"

On Windows create a munit.bat file with the following contents

haxelib run munit %*

and make sure the folder which contains it is under your PATH environment variable. On Windows you can typically place the .bat file in the same folder as haxe.exe.

MUnit Testing Framework

munit uses Haxe metadata to execute test cases at runtime. To create a new test case, simply create an empty class and use the following metadata syntax:

@Test
public function testExample():Void
{
	Assert.isTrue(true);
}

For detailed information on TestCase metadata see Working with test classes

MUnit Build Tool

The munit build tool makes working with unit tests easier and quicker.

To check that the tool is installed

haxelib run munit

This should display summary help information for all the commands. We recommend using the inbuilt help for detailed usage and instructions

haxelib run munit help <command>

More information

"Easter egg"

You can run browser tests directly inside FlashDevelop or HaxeDevelop by specifying -browser flashdevelop

 > munit test -js -browser flashdevelop

Building from source

For general usage developers should use releases installed via haxelib.

A core goal of MUnit is to provide a cross platform unit testing framework across all Haxe targets, but at this point it officially supports only JavaScript, Flash (as2/as3) and Neko targets.

Hopefully over time we can increase this set to include other common targets such as cpp, php and node.js. We welcome contributors for these additional targets.

To get started, below are several resources for where to start...

Known Issues

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

See Known Issues for more details on:

  • Running swf and js tests in Safari
  • Fatal Error in gc under Windows 7 (possibly XP too)
  • HTTP POST causes Nekotools server to hang with JUnit reports (fixed in 2.1.2)
  • haxelib run munit test doesn't return correct error code on OSX