Lua Coverage Tester

Coverage measurements for testing mods. This is a developer tool, not meant for actual gameplay. It is intentionally desync unsafe. Do not use it in multiplayer.
4 months ago
Owner: justarandomgeek
Source: justarandomgeek/factorio-coverage
Homepage: N/A
License: MIT
Created: 4 months ago
Latest Version: 0.17.1 (4 months ago)
Factorio version: 0.17
Downloaded: 24 times

Factorio Coverage Tester

A coverage tool for Factorio Mods, by justarandomgeek.


/startCoverage testname (Command)

Coverage.Start("testname") or"coverage","start","testname") (Script)

Start line counting for all participating mods. Each mod will collect data independently, to be gathered after tests complete.

/stopCoverage (Command)

Coverage.Stop() or"coverage","stop") (Script)

Stop line counting for all participating mods.

/reportCoverage (Command)

Coverage.Report() or"coverage","report") (Script)

Collect test data from all participating mods and write it out to script-outputs\ Automatically stops counting if a test was still running.

Most scripts simply need to pcall(require,'__coverage__/coverage.lua') to be included in line counts. Scenarios/campaign scripts must also provide a path hint to translate "level" to a correct path:

CoverageLoaded,Coverage = pcall(require,'__coverage__/coverage.lua')
if CoverageLoaded then

This form is also useful to provide the Coverage object for Start()/Stop() API calls.

There is a mod setting to enable line counting immediately on control.lua initialization, but this is disabled by default because it makes starting a game very slow.