Automated tests for openfl

I’m interested in a straighforward way to write unit tests for an openfl project
I tried munit like this:
openfl create project SomeProject
haxelib run munit config
This is the resulting munit configuration:

Now write some code with some tests and then:
run munit test -js
it will test classes that don’t use open fl just fine. for the classes that do use openfl it complains it can’t
find openfl.* so I added -lib openfl to the test.hxml (which is used by munit), after which it
complains about lime, so I add -lib lime and then I get:
/usr/lib/haxe/lib/lime/2,4,9/lime/utils/ByteArray.hx:334: characters 30-43 : Unknown identifier : File

So it feels like I’m going about this the wrong way.

It was as simple as adding -D html5 to the javascript section of the hxml.

1 Like

You can take a look at the “tests” directory in OpenFL for how we’re doing it now with munit. It’s a bit of a hack, but currently haxelib run munit test (after “gen”) will do HTML5 and Flash side-by-side, using standard openfl test neko and other commands work for doing desktop native