# mumu-test
**Test suite plugin for the Lava language**
[](LICENSE)
---
## Overview
`mumu-test` is a native plugin for the Lava/MuMu scripting language providing a full-featured test suite runner, test description framework (`describe`/`it`), file assertions, error checks, and test helpers for robust automated testing of Lava plugins, scripts, and applications.
- Write tests in Lava/MuMu using familiar constructs
- Get pretty console reports (with color and clipboard debugging)
- Assert deep equality, error conditions, and file state
- Create test files and temp data easily from Lava/MuMu code
---
## Features
- **`describe` / `it`**: Organize tests in suites
- **Expectations**: `expect_equal`, `expect_not_equal`, `prop_equals`, `has_key`, `test:expect_error`
- **File assertions**: `file_contents_equal`, `file_contents_not_equal`, `file_contents_length_equal`
- **Helpers**: `test:lorem_file` (create lorem test files), `test:unique_filename`
- **Batch runner**: Run all `tests/*.mu` files and see summaries
- **Clipboard debugging**: Output of failing test files copied for quick pasting
- **JSON output**: Suite/test results as JSON lines (for CI/automation)
---
## Installation
Build the plugin as a shared library (`.so`):
```sh
make
make install
```
This copies `libmumutest.so` to `/usr/local/lib/`, as expected by the Lava/MuMu runtime.
---
## Usage
1. **Enable the plugin in Lava/MuMu:**
```lava
> extend("test")
```
2. **Write a test file (e.g., `tests/hello_test.mu`):**
```lava
describe("Sample suite", fn() {
it("should add numbers", fn() {
expect_equal(1 + 1, 2)
})
it("should fail gracefully", fn() {
expect_not_equal("a", "b")
})
it("should throw error", fn() {
test:expect_error(fn() {
error("bad wolf")
}, "wolf")
})
})
```
3. **Run all tests from CLI:**
```sh
lava -e 'test:all(fn(pass) { log(pass) })'
```
- **Or run a single file:**
```sh
lava tests/hello_test.mu
```
---
## API
- **describe(suite_name: string, fn)**
- **it(test_name: string, fn)**
- **expect_equal(actual, expected)**
- **expect_not_equal(actual, expected)**
- **has_key(keyed_array, key)**
- **prop_equals(keyed_array, key, expected_value)**
- **test:expect_error(fn, [optional substring])**
- **file_contents_equal(filename, expected_string)**
- **file_contents_not_equal(filename, unexpected_string)**
- **file_contents_length_equal(filename, expected_len)**
- **test:lorem_file(n_chars)**
- **test:unique_filename()**
- **test:all([opts], callback)**
- **test:run(filename, callback)**
See the source for full parameter details and advanced options.
---
## License
Dual-licensed under **MIT** or **Apache-2.0** (see [LICENSE](LICENSE)).
© 2025 Tom Fotheringham and contributors
---
## Links
- [Lava language website](https://lava.nu11.uk)
- [Plugin repository](https://gitlab.com/tofo/mumu-test)