I’m working on a project, and I’ve developed some tests for it, some of the tests ensure that my code can read a certain xml file.
When I compile my tests, I use a .hxml that looks like this:
-resource assets/data/[email protected]/data/my.xml
However, when I run “neko tests.n”, I get to an area in my code that looks like this:
var content:String = Assets.getText("assets/data/my.xml");
xml = Xml.parse(content);
and I get “Invalid field access : __s” on the second of the above lines.
When I put a trace to find the value of content, it was null.
When I publish or debug my project through FlashDevelop, I get no errors and the XML file is read just fine, the same two lines are even hit without issue.
I really stumped as to what I’m doing wrong.
When I change my hxml to look at a file that doesn’t exist, I get an error, so it’s finding the file, but when I when my code it’s like it’s empty or not found.
That’s not how the assets work, they need the tools to process/include them.
If you want to use
-resource then you need http://api.haxe.org/haxe/Resource.html to access it.
Also your hxml is missing a lot of defines, to see what a project’s hxml looks like you can do
openfl display neko.
Can you use
openfl build for your tests project?
Thank you both for your replies. I’ve copied most of what I see in
however, I’m still getting an error
Called from openfl/Assets.hx line 50
Uncaught exception - Invalid field access : new
when i run my tests.n
Ok, I finally got it to build and work. I just run these two command lines:
haxelib run lime build "Test.xml" neko
haxelib run lime run "Test.xml" neko
Now the only is that when I run these two commands, I get a neko window popping up, but all my tests run. Is there an option to not have a window popup?
Ok, now i’ve figured out I can use:
haxelib run lime test “Test.xml” neko
and it does both of the above things. So, yeah, it all works, it’d be cool if the widow wouldn’t open though, but I can’t find a way to prevent that.
We’ll need to create a window for desktop native to work properly, but perhaps we can do something to make the window remain minimized
Hey, great news
We just added support for hidden windows (in development builds), enabled when using munit. This means the window should not appear when running tests