Module Leste
A testing framework inspired by PestPHP and pytest, designed for Lua.
Functions
init () | Initializes the testing framework. |
cleanup () | Resets the testing framework to its initial state. |
it (describe, test) | Adds a new test case to the Leste.tests array. |
run () | Executes all test cases stored in Leste.tests. |
Tables
Leste |
Functions
- init ()
- Initializes the testing framework. Modifies the assert and print functions based on the framework's settings.
- cleanup ()
- Resets the testing framework to its initial state. Restores original assert, print, and io.write functions.
- it (describe, test)
-
Adds a new test case to the Leste.tests array.
Parameters:
- describe string A description of the test case.
- test function The actual test function to execute.
Usage:
Leste.it("This should be true", function() assert(1 == 1) end)
- run ()
-
Executes all test cases stored in Leste.tests.
Usage:
-- Define the tests Leste.it("This should be true", function() assert(1 == 1) end) -- Then, call the run Leste.run()
Tables
- Leste
-
Fields:
- assertions number Total of assertions in all tests.
- verbose boolean Whether to show or not the print output.
- exitOnFirst boolean Whether to stop running tests after the first failure.
- actualFile string Field used by CLI to store the file name to use later in output.
- stdout table A table to store the arguments passed to the print function.
- refs table A table with references to functions that will be modified.
- tests table An array of test cases, where each test case is a table with a string description and a function to execute.