Skip to content
Unit testing support for Lua Modules
Warframe

Unit testing support for Lua Modules

Documentation for Module:TestHarness, the Scribunto unit test framework used in Warframe. Learn about its functions like th.code_cov and th.run_tests.

By ···10 min read·Multi-source verified
1 reading this guide  

Documentation for Module:TestHarness, the Scribunto unit test framework used in Warframe. Learn about its functions like th.code_cov and th.run_tests.

Hey there, Tenno! So, you're diving into the world of custom scripting in Warframe and want to make sure your Lua modules are as solid as a Rhino's charge? You've landed in the right spot. This page is all about Module:TestHarness, which is basically your go-to tool for writing unit tests for your Lua code within the game's framework.

Think of it like this: before you send your Warframe out on a tough mission, you want to make sure all its mods are working correctly, right? Unit testing is kind of the same thing for your code. It helps you catch bugs early and makes sure everything functions as expected.

Documentation

This module provides a framework for testing your Lua scripts. It's super handy for ensuring the logic in your modules is sound.

Package items

Here are the main functions you'll be working with:

  • th.code_cov(module_name, test_module, test_cases) (function) - This is your code coverage analyzer. It helps you see how much of your code is actually being exercised by your tests.
    • Parameters:
      • module_name: The name of the module you're testing. (string)
      • test_module: The package for your test module. (string)
      • test_cases: The data for your test cases. (string)
    • Returns: Code coverage data. (table)
  • th.run_tests(f) (function) - This is the main test harness function. It kicks off your tests.
    • Parameter: f - The Scribunto frame object. (table)
    • Returns: A test report. (string)
  • utils.format_key(key, If) (function) - A handy little function to format table index keys. It's useful for making your test output cleaner.
    • Parameters:
      • key: The index key for your Lua table. (string or number)
      • If: If set to false, it omits the dot index, which can be useful in certain formatting scenarios. (boolean)
    • Returns: The formatted table index. (string)
  • engine.test_table(member, case, options) (function) - This is your unit tester for package methods. It's where the actual testing happens for specific parts of your module.
    • Parameters:
      • member: The test member you're targeting. (table)
      • case: The specific test case you want to run. (string or number)
      • options: Any additional test options you want to apply. (table)
    • Returns: Test case result data. (table)

See also

For more in-depth technical details, you can check out the official Scribunto documentation on test harnesses: Global Lua Modules/Testharness.

This documentation was created with Docbunto.

See Also

Here's a quick look at some other useful modules and libraries you might encounter or want to link to:

CollapseModules and Lua Libraries
Standard Libraries (STL) Included Scribunto (optional bit32 & libraryUtil)
Extensions M:Math • M:String • M:Table
Databases General M:Codex ( /data) • M:Companions ( /data) • M:Conservation ( /data) • M:DamageTypes ( /data) • M:DojoRoom/data • M:Enemies ( /data) • M:Factions/data • M:FactionScript ( /data) • M:GuaranteedRewards/data • M:Icon ( /data) • M:Keys/data • M:KeyBindings ( /data) • M:Missions ( /data) • M:Music/data • Module:TextIcons ( /data) • M:Upgrades/data • M:Version ( /data)
Warframes M:Ability ( /data) • M:Maximization ( /data) • M:Warframes ( /data)
Weapons M:Modular ( /data) • M:Weapons ( /data, /ppdata)
Upgrades M:Arcane ( /data) • M:Decrees/data • M:Focus ( /data) • M:Mods ( /data) • M:Stances ( /data)
Drop Tables M:Acquisition ( /data) • M:DropTables ( /data) • M:Void ( /data)
Vendors M:Baro ( /data) • M:Vendors ( /data)
Crafting M:Blueprints/data • M:Research ( /data) • M:Resources ( /data)
Cosmetics M:Decorations ( /data) • M:Cosmetics/data • M:Sigils/data • M:TennoGen ( /data)
Infoboxes M:Arcane/infobox • Module:Companions/infobox

100% Human-Written. AI Fact-Checked. Community Verified. Learn how AntMag verifies content