The app I'm build is starting to get big enough that I've decided to add unit testing. After a bit of trolling around I've settled on a testing framework called LunaTest (
http://silentbicycle.com/projects/lunatest/) which is MIT licensed. I'm not using all the randomizing parameters described on that page - just using it as a replacement for lunit.
So, I've got the basics working but it would be convenient if I could run the tests in a coroutine so that I can launch a scene (say) as part of a test setup and yield to wait for it to become available before continuing with the tests. Unfortunately, I found that running the tests inside coroutine crashes the Gideros player.
At first I thought it might be due to the known issue of coroutines and pcall not playing nicely together(
http://lua-users.org/wiki/PcallAndCoroutines). There are apparently solutions to this but, in any case, this is not the immediate problem. I've discovered that the crash occurs if I simply create any Gideros screen objects inside a coroutine. Please try this to see what I mean:
-- main.lua
ExampleScene = Core.class(Sprite)
function ExampleScene:init()
rect=Shape.new()
rect:setPosition(application:getContentWidth()/2, application:getContentHeight()/2)
self:addChild(rect)
stage:addChild(self)
end
local co=coroutine.create(function()
ExampleScene.new()
end)
coroutine.resume(co) |
Is this a bug and can it be fixed?
Best regards
Comments
and the stack trace is:
LuaApplication::orietation() const
ApplicationBinder::getContentWidth(lua_State*)
Now if we only had bi-weekly builds?
As far as I'm aware, @atilim did fix the issues with coroutines though. I use these extensively in the testing solution I came up with.
best regards
For example, if I run it like this:
---- Testing finished in 0.49 ms, with 1 assertion(s) ----
1 passed, 0 failed, 0 error(s), 0 skipped.
However, if I run it like this to force a test failure:
I'm trying to get a good unit testing setup before I go too much further with my current project. Thanks for the info. I guess I'll keep looking.
I'm intrigued by Busted, but I'm still trying to figure out how to fold it into a Gideros-based project.
The BhEventShield looks interesting and useful, though. Thanks for sharing it. My game is very gesture-based, so this might help in setting up the testing.