Unit Tests

Anyone out there have any strong opinions about which unit testing frameworks to use with Corona?

http://lua-users.org/wiki/UnitTesting

I’d like to setup a workflow where we push code to GitHub and then use CircleCI to kick off the tests – resulting in a PR that can be merged in or blocked.

I’m leaning towards Lunatest based on this article.  http://jessewarden.com/2012/07/unit-testing-in-corona-sdk-using-lunatest.html

No, but interested to hear about your findings.

Basically, loading your testing code with require statement in main.lua, the entry point of Corona SDK projects.  Lua support assert statement; therefore, whether applying unit test framework or not is not of the most importance.

Sometimes I implemented non-UI code, writing some assertions without any unit test framework, in a separated environment like ZeroBrane Studio.  When all tests passed, I copied these Lua scripts into my Corona SDK project.  Not the best practice but handy.  Occasionally, the Lua interpreter in Corona SDK behaved differently when comparing with other Lua interpreters; minor modification would suffice in this situation.

Michael

Hello nathan, so far the best unit test platform for Lua is Busted: https://github.com/Olivine-Labs/busted, the community has also made some mocks to make it work with this library: https://github.com/Cluain/corona-busted . Also, you can find an example of usage on this link: https://github.com/chris-allnutt/unit-tested-corona

BUT, even with these mocks I found it very frustrating to do unit tests/integration tests on Corona. Hope it get better on future. 

See you.

Thanks everyone for the comments.  I agree – I wish there was some stronger unit testing built around Corona.  Where it tends to lend itself to fast prototyping and delivery I can see where it’s been skipped over.  In any case, I’m glad @lsoaresesilva7 mentioned busted because after looking through all of the unit testing frameworks I chose that one with luaunit on backup.  I also found a linter called luacheck that seems to work great and so I was going to look at that for static analysis of the code.  Basically run luacheck and luaunit before allowing a PR to be merged using CircleCI.

No, but interested to hear about your findings.

Basically, loading your testing code with require statement in main.lua, the entry point of Corona SDK projects.  Lua support assert statement; therefore, whether applying unit test framework or not is not of the most importance.

Sometimes I implemented non-UI code, writing some assertions without any unit test framework, in a separated environment like ZeroBrane Studio.  When all tests passed, I copied these Lua scripts into my Corona SDK project.  Not the best practice but handy.  Occasionally, the Lua interpreter in Corona SDK behaved differently when comparing with other Lua interpreters; minor modification would suffice in this situation.

Michael

Hello nathan, so far the best unit test platform for Lua is Busted: https://github.com/Olivine-Labs/busted, the community has also made some mocks to make it work with this library: https://github.com/Cluain/corona-busted . Also, you can find an example of usage on this link: https://github.com/chris-allnutt/unit-tested-corona

BUT, even with these mocks I found it very frustrating to do unit tests/integration tests on Corona. Hope it get better on future. 

See you.

Thanks everyone for the comments.  I agree – I wish there was some stronger unit testing built around Corona.  Where it tends to lend itself to fast prototyping and delivery I can see where it’s been skipped over.  In any case, I’m glad @lsoaresesilva7 mentioned busted because after looking through all of the unit testing frameworks I chose that one with luaunit on backup.  I also found a linter called luacheck that seems to work great and so I was going to look at that for static analysis of the code.  Basically run luacheck and luaunit before allowing a PR to be merged using CircleCI.