|
| 1 | +*plenary-test* |
| 2 | + |
| 3 | + |
| 4 | +Supports (simple) busted-style testing. It implements a mock-ed busted |
| 5 | +interface, that will allow you to run simple busted style tests in separate |
| 6 | +neovim instances. |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +USAGE *plenary-test-usage* |
| 11 | +============================================================================== |
| 12 | + |
| 13 | +To run the current spec file in a floating window, you can use the keymap |
| 14 | +`<Plug>PlenaryTestFile`. For example: |
| 15 | +> |
| 16 | + nmap <leader>t <Plug>PlenaryTestFile |
| 17 | +< |
| 18 | +In this case, the test is run with a minimal configuration, that includes in |
| 19 | +its runtimepath only plenary.nvim and the current working directory. |
| 20 | + |
| 21 | +To run a whole directory from the command line, you could do something like: |
| 22 | +> |
| 23 | + nvim --headless -c "PlenaryBustedDirectory tests/plenary/ { <options> }" |
| 24 | +
|
| 25 | +Where the first argument is the directory you'd like to test. It will search |
| 26 | +for files with the pattern `*_spec.lua` and execute them in separate neovim |
| 27 | +instances. |
| 28 | + |
| 29 | +The second argument is a Lua option table with the following fields: |
| 30 | + |
| 31 | + `nvim_cmd` specify the command to launch this neovim instance (defaults |
| 32 | + to `vim.v.progpath`). |
| 33 | + `init` specify an init.vim to use for this instance, if not given |
| 34 | + a minimal configuration is used. |
| 35 | + `minimal_init` as for `init`, but also run the neovim instance with |
| 36 | + `--clean`. |
| 37 | + `sequential` whether to run tests sequentially (default is to run in |
| 38 | + parallel). |
| 39 | + `keep_going` if `sequential`, whether to continue on test failure (default |
| 40 | + true). |
| 41 | + `timeout` controls the maximum time allotted to each job in parallel or |
| 42 | + sequential operation (defaults to 50,000 milliseconds). |
| 43 | + |
| 44 | +Unless `init` is given, the neovim instance is run with the `--clean` |
| 45 | +argument. |
| 46 | + |
| 47 | +The exit code is 0 for success and 1 for fail, so you can use it easily in |
| 48 | +a `Makefile`. |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +SUPPORTED BUSTED ITEMS *plenary-test-busted* |
| 53 | +============================================================================== |
| 54 | + |
| 55 | +So far, the only supported busted items are: |
| 56 | + |
| 57 | +- `describe` |
| 58 | +- `it` |
| 59 | +- `pending` |
| 60 | +- `before_each` |
| 61 | +- `after_each` |
| 62 | +- `clear` |
| 63 | +- `assert.*` etc. (from luassert, which is bundled) |
| 64 | + |
| 65 | +We used to support `luaunit` and original `busted` but it turns out it was way |
| 66 | +too hard and not worthwhile for the difficulty of getting them setup, |
| 67 | +particularly on other platforms or in CI. Now, we have a dep free (or at |
| 68 | +least, no other installation steps necessary) `busted` implementation that can |
| 69 | +be used more easily. |
| 70 | + |
| 71 | +Please take a look at the new APIs and make any issues for things that aren't |
| 72 | +clear. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +COMMANDS *plenary-test-commands* |
| 77 | +============================================================================== |
| 78 | + |
| 79 | +*:PlenaryBustedFile* {path} |
| 80 | + |
| 81 | + Run a test on a single `_spec.lua` file. |
| 82 | + |
| 83 | + |
| 84 | +*:PlenaryBustedDirectory* {path} {options} |
| 85 | + |
| 86 | + Run tests for all `*_spec.lua` files in the given path. |
| 87 | + |
| 88 | + {options} is a table, see |plenary-test-usage|. |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +PLUGS *plenary-test-plugs* |
| 94 | +============================================================================== |
| 95 | + |
| 96 | +<Plug>PlenaryTestFile |
| 97 | + |
| 98 | + Can be used to run a test on a single file, with a minimal configuration. |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +LICENSE *plenary-test-license* |
| 104 | +============================================================================== |
| 105 | + |
| 106 | +MIT license |
| 107 | + |
| 108 | + |
| 109 | +============================================================================== |
| 110 | +vim:tw=78:ft=help:norl:et:ts=2:sw=2:fen:fdl=0: |
0 commit comments