luaunit icon indicating copy to clipboard operation
luaunit copied to clipboard

Local test groups and their order of execution.

Open DKnoto opened this issue 5 months ago • 0 comments

Static analysis using Luacheck for such a set of tests:

local lu = require "luaunit";

TestFirst = {};

function TestFirst:test_01()
    --
end;

TestOther = {};

-- ...

os.exit(lu.LuaUnit.run());

Shows:

FunctionsTest.lua:3:1: setting non-standard global variable TestFirst
FunctionsTest.lua:5:10: mutating non-standard global variable TestFirst
FunctionsTest.lua:5:19: unused argument self

I would expect an alternative approach:

local lu = require "luaunit";

local TestFirst = {};

function TestFirst:test_01()
    -- ...
end;

local TestOther = {};

-- ...

os.exit(lu.LuaUnit.run({TestFirst, TestOther}));

This approach will not generate these warnings, making it easier to analyze the content of the test, and it would also make it easier to determine the order of tests at the group level.

DKnoto avatar Sep 12 '24 18:09 DKnoto