RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

cdefDebugDraw ReferencecdefGpuMesh ReferencecdefImgui ReferencecdefMath Referencecdefs ReferencecontrolSystems Referencecsvlib ReferencedelayLine Referencedequeue ReferencedevUtils ReferenceEvent Referenceextensions Referencefilters Referencegraphpath Referenceguihooks ReferenceinputFilters ReferenceinterpolatedMap Referenceintrospection ReferencejbeamWriter Referencejson-ast Referencejson ReferencejsonDebug ReferencejsonPrettyEncoderCustom Referencekdtreebox2d Referencekdtreebox3d Referencekdtreepoint3d Referencelpack ReferenceluaBinding ReferenceluaCore ReferenceluaProfiler Referencemathlib Referenceparticles Referencequadtree Referencesettings ReferencetcpServer ReferencetimeEvents Referenceutils Reference
testFramework/ - Unit Testing FrameworkJUnitXMLWriter ReferenceTestManager Reference

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferencecommontestFramework

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 _shouldFail to test name for expected-failure tests
  • Uses JUnitXMLWriter for XML output
  • Uses socket for timing (high-resolution)
  • Tracks pass/fail counts in __internal table
  • currentCtx holds 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.

On this page

ExportsTestManager ClassTestManager:setLogDefault(logLevel)TestManager:run(tests, outputFile)ConstantsTestManager.LogAlwaysTestManager.LogErrorsTestManager.LogFailsUsageInternal Notes