TestManager Reference
Module defined in `lua/common/testFramework/TestManager.lua`. Unit test manager for BeamNG - collects test functions, executes them, logs results, and outputs JUnit XML reports.
Module defined in lua/common/testFramework/TestManager.lua. Unit test manager for BeamNG - collects test functions, executes them, logs results, and outputs JUnit XML reports.
Exports
The module uses a class-based pattern. No direct M. function exports - instead, create a TestManager instance and call methods on it.
TestManager Class
TestManager:setLogDefault(logLevel)
Set the default log level for test output.
- Parameters:
logLevel- number - Log level (LogAlways=1, LogErrors=2, LogFails=3)
TestManager:run(tests, outputFile)
Run all test functions in the provided table.
- Parameters:
tests- table - Table of test functions (names starting with "test")outputFile- string|nil - Optional JUnit XML output file path
Constants
TestManager.LogAlways
- Type: number (1)
- Description: Log all test output
TestManager.LogErrors
- Type: number (2)
- Description: Log only errors
TestManager.LogFails
- Type: number (3)
- Description: Log only failures
Usage
local testManager = require('testFramework/TestManager')
local tests = {
testSomething = function() assert(true) end,
testShouldFail_shouldFail = function() error("expected") end,
}
testManager:run(tests, 'results.xml')Internal Notes
- Test functions must be named starting with
test - Append
_shouldFailto test name for expected-failure tests - Uses
JUnitXMLWriterfor XML output - Uses
socketfor timing (high-resolution) - Tracks pass/fail counts in
__internaltable currentCtxholds the current test context during execution
JUnitXMLWriter Reference
Module defined in `lua/common/testFramework/JUnitXMLWriter.lua`. Writes test results in JUnit XML format for CI/CD integration.
calltracer Reference
Module defined in `lua/common/utils/calltracer.lua`. Records function call graphs using Lua's debug hook, exports to TGF format for visualization in yEd.