Now, I'm curious if MUnit was tested with FlashDevelop, because I'm getting something strange regarding code completion. If I type "Assert." (even in the example file, whose test passes; right below a line also beginning with "Assert.") and wait to see which methods I can use, I get the following in the Output pane:
Error: Could not process argument #--macro Class name must start with uppercase character
It does not pop up a list of methods. I get the same error if I hit F4 over the token Assert, which is coloured blue to show it's correctly imported. Hmm...so, that's problem 1. Update: I found this handy info from here:
Except that adding the "munit" line as above--to a default project.xml I had to create (with current templates I have yet to come across application.xml so I believe that's outdated and/or openfl-specific rather than haxeflixel-specific)--only changed the error whenever I try autocompletion to:
There’s just one last thing required to properly get up and running writing tests: adding the munit library to the project so that you can get code-completion on munit’s API. Open
application.xmland add the line
<haxelib name="munit" />to the classpath, haxe libs section so it looks like:
<!-- classpath, haxe libs --> <source path="src" /> <haxelib name="openfl" /> <haxelib name="actuate" /> <haxelib name="munit" />
Invalid commandline class : test.ExampleTest should be ExampleTest ./test/ExampleTest.hx:3: characters 7-31 : Type not found : massive.munit.util.Timer
That's on the import line. If I remove that, then it can't find the Timer class referenced in the example. Back to the drawing board...well, hopefully not that far back.
Meanwhile, if I try to write a test anyway, my characterAIAimsAndFires class was apparently mal-named, despite following the naming convention in the help, because the compiler complains (via macros, while I type code for the test) that the file name ought not to start with a lowercase letter. So now it's CharacterAIAimsAndFires. In its setup(), I call FlxG.switchState() to get my main world set up--just for now, until I properly decouple some of my code, I suppose.
Just adding the above and trying to compile, I get an error about TestMain, that it can't find FlxG. That's because test.hxml also needs some lines like these:
-lib flixel -lib flixel-addons -lib scrollable-area -lib nape -lib advanced-layout
...or at least the first one, in this case. But I thought since I'll be testing pretty broadly, I should include whatever I have included in my Project.xml via haxelib directives.
Turns out that's not enough:
HaxeWrapper.hx:73: C:\HaxeToolkit\haxe\lib\openfl/3,6,0/openfl/display/IBitmapDrawable.hx:17: characters 8-66 : Type not found : RenderSession Error: Error compiling hxml for as3
Now, even if I add "-lib openfl" and "-lib lime", I still get this. So that's problem 2, which is significantly bigger than problem 1...
I see that IBitmapDrawable refers to RenderSession via the package openfl._internal.renderer, but its entire contents are conditionally compiled "#if (!display && !flash)". I guess either display or flash is defined true when compiling with munit, but not normally.
Likewise if I target cpp instead of flash (which my game compiles to without trouble) in the test.hxml file, I get this:
HaxeWrapper.hx:73: C:\HaxeToolkit\haxe\lib\flixel/git/flixel/FlxGame.hx:3: characters 7-27 : You cannot access the flash package while targeting cpp (for flash.display.Bitmap) HaxeWrapper.hx:73: test/unit/TestMain.hx:1: characters 7-21 : referenced here Error: Error compiling hxml for cpp