bluebird75 / luaunit

LuaUnit is a popular unit-testing framework for Lua, with an interface typical of xUnit libraries (Python unittest, Junit, NUnit, ...). It supports several output formats (Text, TAP, JUnit, ...) to be used directly or work with Continuous Integration platforms (Jenkins, Maven, ...).
Other
565 stars 136 forks source link

Running tests across multiple files #150

Closed scottsym closed 1 year ago

scottsym commented 1 year ago

@bluebird75 (or others),

This is an excellent tool that I've recently started using, thank you!

The biggest thing I'm currently trying to figure out is how to best run all LuaUnit unit tests across multiple *.lua files and get a single summary report of failures from across all of those different files' test cases, if possible. Each .lua file has a table of test functions that are discovered by the execution of os.exit( lu.LuaUnit.run('-v') ) at the the end of the file.

Is there a recommended mechanism for doing this easily?

Thanks!

bluebird75 commented 1 year ago

So far, there is nothing facilitating running tests from multiple files the way you describe it. I made the choice for luaunit to only depend on natively provided libraries by lua. Thoses libraries do not have file handling capabilities, limiting the capabilities for proper multi-file testing.

I should probably consider to optionally depend on one of the filesystem libraries availble for lua to extend the capabilites of LuaUnit.

In the meantime, the only thing you can do is to explicitily put the test files in the global namespace, or to run luaunit with an explicit list of tables of tests, the list being constructed by requiring all your lua test files one by one.

scottsym commented 1 year ago

Thanks for the response, @bluebird75...I was thinking of doing the latter approach, so thanks for confirming!