This document describes how to run tests for focus.nvim.
This project uses mini.test as the testing framework.
To run all tests in the project:
make testTo run a specific test file:
make test_file FILE=tests/test_ui.luaAvailable test files:
tests/test_ui.lua- UI-related tests (signcolumn, cursorline, number, etc.)tests/test_autoresize.lua- Autoresize functionality teststests/test_splits.lua- Split window teststests/test_setup.lua- Setup and configuration tests
By default, tests show minimal output. You can increase verbosity using the GROUP_DEPTH parameter:
make testShows only file names with pass/fail symbols:
tests/test_ui.lua: oooooooooooooo
make test GROUP_DEPTH=2Shows file name and test group:
tests/test_ui.lua | focus_ui: oooooooooooooo
make test_file FILE=tests/test_ui.lua GROUP_DEPTH=3Shows file name, group name, and individual test names:
tests/test_ui.lua | focus_ui | number: o
tests/test_ui.lua | focus_ui | number with split: o
tests/test_ui.lua | focus_ui | signcolumn respects disabled state on WinLeave: o
...
You can combine test_file with GROUP_DEPTH:
make test_file FILE=tests/test_ui.lua GROUP_DEPTH=3o(green) - Test passedx(red) - Test faileds- Test skipped
If you prefer to run tests manually without the Makefile:
nvim --headless --noplugin -u ./tests/minimal_init.lua \
-c "lua require('mini.test').setup()" \
-c "lua MiniTest.run({ execute = { reporter = MiniTest.gen_reporter.stdout({ group_depth = 3 }) } })"For a specific file:
nvim --headless --noplugin -u ./tests/minimal_init.lua \
-c "lua require('mini.test').setup()" \
-c "lua MiniTest.run_file('tests/test_ui.lua', { execute = { reporter = MiniTest.gen_reporter.stdout({ group_depth = 3 }) } })"Tests are organized in the tests/ directory. Each test file should:
- Load the test helpers:
local helpers = dofile('tests/helpers.lua') - Create a child Neovim instance:
local child = helpers.new_child_neovim() - Define test sets using
MiniTest.new_set() - Use expectations like
eq(),neq(),expect.equality(), etc.
See existing test files for examples.
- Neovim 0.8.0 or later
- Tests run in headless mode and do not require a display