Create a test file (example/test.lua) with the below content
luaunit = require('luaunit')
function testPass()
luaunit.assertEquals({1, 2, 3}, {1, 2, 3})
end
function testFail()
luaunit.assertEquals({1, 2, 3}, {1, 2, 4})
end
-- Use LuaUnit.run(...) with varargs if you want to use Local Lua Debugger for debugging
os.exit(luaunit.LuaUnit.run())
If the Lua executable is not available via lua create .vscode/settings.json. The current workspace folder can be referred to as ${workspaceFolder}, e.g. "${workspaceFolder}/lua5.1.exe"
For debugging capability install one of the supported debug extensions (see Supported) and set luaTestAdapter.debugExtension if not using the default
Run (or debug) the tests via the Test Explorer UI
Configuration
Property
Description
luaTestAdapter.luaExe
Path to Lua executable. The current workspace folder can be referred to using ${workspaceFolder}. Defaults to lua
luaTestAdapter.testGlob
Glob used to find test files. Defaults to **/[tT]est*.{lua}
luaTestAdapter.testRegex
Regex matched against function/method names to identify tests. Defaults to ^[tT]est[a-zA-Z0-9_]*$
luaTestAdapter.suiteRegex
Regex matched against class names in function ClassName:method() syntax to identify test suites. Defaults to ^Test[a-zA-Z0-9_]*$
luaTestAdapter.testEncoding
Test file encoding. Defaults to utf8
luaTestAdapter.decorationRegex
Regex used to find line number and failure message in test output. Defaults to /\.lua:(?<line>[1-9][0-9]*):(?<message>.*)stack traceback:/
luaTestAdapter.debugExtension
Debug extension used to debug tests. One of actboy168.lua-debug (default), tomblind.local-lua-debugger-vscode, or ismoh-games.second-local-lua-debugger-vscode