Skip to content

Lej/vscode-lua-test-adapter

Repository files navigation

LuaUnit Test Adapter for Visual Studio Code

Lua Test Adapter (https://marketplace.visualstudio.com/items?itemName=lej.vscode-lua-test-adapter) This is a LuaUnit test adapter for Test Explorer UI (https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer)

Supported

Not supported

  • Automatic reloading of test definitions
  • Autorun

Example

An example similar to the one described below in Getting Started can be found here:

Getting Started

  1. Create an empty folder example
  2. Download LuaUnit (example/luaunit.lua)
  1. 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

os.exit(luaunit.LuaUnit.run())
  1. 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"
{
  "luaTestAdapter.luaExe": "C:/Program Files/Lua/lua-5.1.5_Win64_bin/lua5.1.exe",
}
  1. Install Test Explorer UI
  1. Install Lua Test Adapter
  1. For debugging capability install Lua Debug
  1. 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 used to find tests. Defaults to /^\s*function\s+(?:[a-zA-Z][a-zA-Z0-9]*:)?(?<test>[tT]est[a-zA-Z0-9]*)\(\)(?:.*)$/
luaTestAdapter.testEncoding Test file encoding. Defaults to utf8
luaTestAdapter.decorationRegex Regex used to find line number and failure message. Defaults to /\.lua:(?<line>[1-9][0-9]*):(?<message>.*)stack traceback:/

About

LuaUnit Test Adapter implementation for Test Explorer UI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published