A fast test runner that works out of the box. Zero dependencies.
- Tests are written in Lua (but you don't need Lua installed on your system)
- Batteries included for API testing
$ testbox - <<EOF
test("just a test", function()
expect_equal(2, 1 + 1)
end)
test("this will fail!", function()
expect_equal(1, 2)
end)
EOF
# Prints out:
✅ just a test
❌ this will fail!
Not equal!
Left: 1
Right: 2If you have cargo/rust on your system:
$ cargo install testbox
...
$ testbox --versionOtherwise you can just download the compiled executable from the releases page.
$ testbox - <<EOF
test("API test: get users", function()
exec_bg("cd path/to/my/app ; npm run dev", {
wait = function(stdout, stderr)
return string.match(stdout, "Server is ready") ~= nil
end
})
local response = fetch({
url = "http://localhost:3000/api/users",
method = "GET",
})
expect_equal(response.json.users[1].email, "someuser@example.com")
end)
EOFtestbox - <<EOF
test("uppercase text with awk", function()
expect_equal(
exec([[echo foobar | awk '{print toupper($0)}']]).output,
"FOOBAR",
)
end)
EOFThe examples above use helper functions such as exec_bg and fetch. These functions are part of the Testbox Library, which you can learn more about here.