Skip to content

Instantly share code, notes, and snippets.

@tiagolr
Created July 3, 2014 22:35
Show Gist options
  • Save tiagolr/d7e82f2009dbc90e9a66 to your computer and use it in GitHub Desktop.
Save tiagolr/d7e82f2009dbc90e9a66 to your computer and use it in GitHub Desktop.
Std unit tests template
bin
.temp
report.txt
:: Creates coverage report and saves it to report.txt file.
:: MCoverage lib must be installed
@echo off
CALL lime test neko -debug -DCOVERAGE > report.txt
<?xml version="1.0" encoding="utf-8"?>
<project>
<app main="TestMain" file="test" path="bin" />
<set name="SHOW_CONSOLE" value="1"/>
<haxedef name="SHOW_CONSOLE"/>
<haxelib name="openfl" />
<!-- Code coverage -->
<!-- Compile with flag COVERAGE to view code coverage, eg: lime test neko -DCOVERAGE -->
<!-- Adjust packages classpath (['../src']) if necessary -->
<haxelib name="mcover"/>
<haxeflag name="--macro" value="mcover.MCover.coverage([''], ['../src'], null)" />
</project>
@echo off
call lime test flash -debug
pause
call lime test neko -debug
pause
call lime test cpp -debug
pause
package ;
import haxe.unit.TestCase;
/**
* Simple test case
*/
class TestExample extends TestCase
{
public function new() {
super();
}
override public function setup() {
}
override public function tearDown() {
}
public function testExample() {
assertTrue(true);
}
}
package ;
class TestMain {
static function main(){
var r = new haxe.unit.TestRunner();
r.add(new TestExample());
r.run();
#if COVERAGE
var logger = mcover.coverage.MCoverage.getLogger();
logger.report();
#end
#if !flash
Sys.exit(0);
#end
}
}
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="Application" />
<movie input="" />
<movie path="project.xml" />
<movie fps="30" />
<movie width="800" />
<movie height="600" />
<movie version="3" />
<movie minorVersion="0" />
<movie platform="NME" />
<movie background="FFFFFF" />
<movie preferredSDK=";3;" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
</classpaths>
<!-- Build options -->
<build>
<option flashStrict="False" />
<option noInlineOnDebug="False" />
<option mainClass="ApplicationMain" />
<option enabledebug="True" />
<option additional="--no-output&#xA;--remap flash:openfl&#xA;--macro mcover.MCover.coverage([''], ['../src'], null)&#xA;#--macro keep(&quot;TestRunner&quot;)" />
</build>
<!-- haxelib libraries -->
<haxelib>
<!-- example: <library name="..." /> -->
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<compile path="src\Main.hx" />
</compileTargets>
<!-- Assets to embed into the output SWF -->
<library>
</library>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<hidden path="obj" />
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand />
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment