We use LuaUnit to test the SDK and firmware in the simulator and device. If you want to use it you can do the following:
IMPORTANT: we're using luaunit 3.2.1. YMMV with other version.
-
copy the luaunit source into your source folder
-
Add these patch files to the lauunit source folder.
panic-luaunit.zip (22.2 KB) -
In your main.lua add the following to the top
import 'luaunit/playdate_luaunit_fix'
import 'luaunit/luaunit'
-
Import your unit tests
-
run luaunit with the following:
-- turns off updating
playdate.stop()
-- when outputting a table, include a table address
luaunit.PRINT_TABLE_REF_IN_ERROR_MSG = true
-- process the command line args (if any)
local testOutputFilename = "test_output"
local outputType = "text"
local luaunit_args = {'--output', 'text', '--verbose', '-r'}
-- run the tests
local returnValue = luaunit.LuaUnit.run(table.unpack(luaunit_args))
print("unit test return value = "..returnValue)
CAVEATS: I haven't tested these instructions directly. They're simply taken from what we're doing with our own code.