Write unit test file which name suffixed with "_spec.lua" in same directory with source file.
Just run make test
to excute unit test.
If you want more operations, read below sections.
Open unit test file in nvim. Run :TestLuaSpec
to run unit test.
To run a whole directory "./lua" from the command line.
nvim --headless -c "PlenaryBustedDirectory lua"
nvim --headless -c "lua require('plenary.test_harness').test_directory('lua', { timeout = 5000 })"
The second argument is a Lua option table with the following fields:
- minimal_init: specify an init.vim to use for this instance, uses --noplugin
- minimal: uses --noplugin without an init script (overrides minimal_init)
- sequential: whether to run tests sequentially (default is to run in parallel)
- keep_going: if sequential, whether to continue on test failure (default true)
- timeout: controls the maximum time allotted to each job in parallel or sequential operation (defaults to 50,000 milliseconds)
See Test Guide for mocking and assert.