silentbicycle/lunatest

All suites get the name "main"

Opened this issue · 2 comments

I got a simple test-all.lua as follows:

package.path = package.path .. ";../?.lua;lunatest/?.lua;mockobjects/?.lua;../rapanui-sdk/?.lua"

require "lunatest"

lunatest.suite("RNLayerTest")
lunatest.suite("RNScreenTest")


lunatest.run()

this ends up with output:

-- Starting suite "main", 14 test(s)
  ..............
---- Testing finished in 0.00 ms, with 66 assertion(s) ----
  14 passed, 0 failed, 0 error(s), 0 skipped.

-- Starting suite "main", 36 test(s)
  ....................................
---- Testing finished in 0.00 ms, with 422 assertion(s) ----
  36 passed, 0 failed, 0 error(s), 0 skipped.

This may be happening because your suites files aren't modules. If you add e.g.

module(..., package.seeall)

at the beginning, it should give them their proper names. I'm seeing

 * Error loading test suite "RNLayerTest":
./lunatest.lua:570: bad argument #1 to 'pairs' (table expected, got boolean)

when I run that kind of setup. Is that your root cause? There are various ways I could handle this (by noticing that require is returning true, rather than a table).

Yes, I was missing the module() from the test files. Adding those apparently breaks all my includes or messes my package path or something, need to do some more investigating.