This is a personal fork of lej.vscode-lua-test-adapter with additional features for personal use.
A LuaUnit test adapter for Test Explorer UI.
Supported
- Detect LuaUnit tests
- Run LuaUnit tests
- Debugging (requires one of the extensions below, configurable with
debugExtension)- Lua Debug by actboy168 (default)
- Local Lua Debugger by tomblind
- The test file must pass varargs to LuaUnit so the debugger can forward test filter arguments:
LuaUnit.run(...)orLuaUnit.new():runSuite(...)
- The test file must pass varargs to LuaUnit so the debugger can forward test filter arguments:
- Second Local Lua Debugger by ismoh-games (fork of tomblind's)
- Same requirement as Local Lua Debugger: the test file must use
LuaUnit.run(...)orLuaUnit.new():runSuite(...)
- Same requirement as Local Lua Debugger: the test file must use
Not supported
- Automatic reloading of test definitions
- Autorun
Getting Started
- Install LuaUnit Test-Adapter
- Download LuaUnit (
example/luaunit.lua) - 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 on
PATHaslua, setluaExein settings. Use${workspaceFolder}to reference the workspace root, e.g."${workspaceFolder}/lua5.1.exe" - Test Explorer UI is installed automatically as necessary. Newer version of VSCode has this feature built-in so no need to install the extension.
- For debugging capability install one of the supported debug extensions (see Supported) and set
debugExtensionif not using the default - Run (or debug) the tests via the Test Explorer UI
Configuration
| Property | Description |
|---|---|
luaExe |
Path to Lua executable. Defaults to lua |
testGlob |
Glob used to find test files. Defaults to **/[tT]est*.{lua} |
testRegex |
Regex matched against function/method names to identify tests. Defaults to ^[tT]est[a-zA-Z0-9_]*$ |
suiteRegex |
Regex matched against class names in function ClassName:method() syntax to identify test suites. Defaults to ^Test[a-zA-Z0-9_]*$ |
testEncoding |
Test file encoding. Defaults to utf8 |
decorationRegex |
Regex used to find line number and failure message in test output. Defaults to /\.lua:(?<line>[1-9][0-9]*):(?<message>.*)stack traceback:/ |
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 |