Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Using Busted with Gideros — Gideros Forum

Using Busted with Gideros

troysandaltroysandal Member
edited July 2013 in Game & application design
I'm new to Gideros and Lua so apologies if this is answered elsewhere despite my searches. I'm using Busted to test my new Gideros application. Busted works fine unless I'm trying to test a module that in some way requires Core, i.e. Core.class(), in which case I get the error "module 'Core' not found". Core is implicit in Gideros's build and I haven't found a way to require 'Core'. In the ZeroBrane Debugger I notice a file called property.lua that is apparently where Core lives but I can't find property.lua anywhere in the Gideros libraries.

I've worked around this by writing my own TCore.class() function that's compatible with Core.class() but am wondering if others have either worked around this or know how to require Core in a busted test.

Thank you in advance.

-Troy, aka Gideros/Lua Newby

Comments

  • atilimatilim Maintainer
    edited August 2013
    maybe you can create a file TCore.lua with this content:
    TCore = Core
    return TCore
    so that you can use require "TCore" and TCore.class().
  • Atilim, that works if Core is available which only seems true when running via the Gideros Player, not when running via busted in a bash shell. If Core = nil then TCore = nil if I'm reading you right? I'm starting to think that Core is an internal Gideros class that's pre-compiled via luac or is implemented in native code.

    Thanks.
  • @troysandal: Was taking a look at Busted, pretty intrigued because I like the rspec style of tests. I was just curious how you integrated it with Gideros and if you ever got around the issue you were having.

    I'm still pretty green with Lua and Gideros. I've installed Busted via luarocks, but I don't know how to make the Gideros runtime aware of it. I think I'm missing a few pieces.
  • @Vramin - I'm still using my own TCore classes so I can used busted. Here's a Gist you can use. Gideros isn't aware of busted as busted runs your code in it's own Lua environment. You'll run your busted tests from a shell which is where you hit the issue of Core not being available. What I did was make all my model classes or anything else that's unit testable derive from TCore.class() and wrote busted tests only against those classes. All my UI classes use Core.class(). This has proved to be effective as TCore and Core use the same syntax though they aren't compatible, e.g. TCore.class(EventDispatcher) fails. You'll want to write a TEventDispatcher class in order to provider event dispatching during your unit tests. I haven't needed it yet.

    Good luck.

    https://gist.github.com/troysandal/6678407
Sign In or Register to comment.