diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/README.md | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/test/README.md b/test/README.md index 60279589b1..64892b5576 100644 --- a/test/README.md +++ b/test/README.md @@ -140,7 +140,7 @@ To run a *specific* functional test: To *repeat* a test: - .deps/usr/bin/busted --lpath='build/?.lua' --filter 'foo' --repeat 1000 test/functional/ui/foo_spec.lua + BUSTED_ARGS="--repeat=100 --no-keep-going" TEST_FILE=test/functional/foo_spec.lua make functionaltest ### Filter by tag @@ -173,43 +173,27 @@ Writing tests Guidelines ---------- -- Consider [BDD](http://en.wikipedia.org/wiki/Behavior-driven_development) - guidelines for organization and readability of tests. Describe what you're - testing (and the environment if applicable) and create specs that assert its - behavior. -- For testing static functions or functions that have side effects visible only - in module-global variables, create accessors for the modified variables. For - example, say you are testing a function in misc1.c that modifies a static - variable, create a file `test/c-helpers/misc1.c` and add a function that - retrieves the value after the function call. Files under `test/c-helpers` will - only be compiled when building the test shared library. - Luajit needs to know about type and constant declarations used in function prototypes. The [helpers.lua](https://github.com/neovim/neovim/blob/master/test/unit/helpers.lua) file automatically parses `types.h`, so types used in the tested functions - must be moved to it to avoid having to rewrite the declarations in the test - files (even though this is how it's currently done currently in the misc1/fs - modules, but contributors are encouraged to refactor the declarations). - - Macro constants must be rewritten as enums so they can be "visible" to the - tests automatically. -- Busted supports various "output providers". The - **[gtest](https://github.com/Olivine-Labs/busted/pull/394) output provider** - shows verbose details that can be useful to diagnose hung tests. Either modify - the Makefile or compile with `make - CMAKE_EXTRA_FLAGS=-DBUSTED_OUTPUT_TYPE=gtest` to enable it. -- **Use busted's `pending()` feature** to skip tests + could be moved to it to avoid having to rewrite the declarations in the test + files. + - `#define` constants must be rewritten `const` or `enum` so they can be + "visible" to the tests. +- Use **pending()** to skip tests ([example](https://github.com/neovim/neovim/commit/5c1dc0fbe7388528875aff9d7b5055ad718014de#diff-bf80b24c724b0004e8418102f68b0679R18)). Do not silently skip the test with `if-else`. If a functional test depends on some external factor (e.g. the existence of `md5sum` on `$PATH`), *and* you can't mock or fake the dependency, then skip the test via `pending()` if the external factor is missing. This ensures that the *total* test-count (success + fail + error + pending) is the same in all environments. - - *Note:* `pending()` is ignored if it is missing an argument _unless_ it is + - *Note:* `pending()` is ignored if it is missing an argument, unless it is [contained in an `it()` block](https://github.com/neovim/neovim/blob/d21690a66e7eb5ebef18046c7a79ef898966d786/test/functional/ex_cmds/grep_spec.lua#L11). Provide empty function argument if the `pending()` call is outside of `it()` ([example](https://github.com/neovim/neovim/commit/5c1dc0fbe7388528875aff9d7b5055ad718014de#diff-bf80b24c724b0004e8418102f68b0679R18)). -- Really long `source([=[...]=])` blocks may break syntax highlighting. Try - `:syntax sync fromstart` to fix it. +- Really long `source([=[...]=])` blocks may break Vim's Lua syntax + highlighting. Try `:syntax sync fromstart` to fix it. Where tests go -------------- @@ -254,6 +238,8 @@ Test behaviour is affected by environment variables. Currently supported treated as Integer; when defined, treated as String; when defined, treated as Number; !must be defined to function properly): +- `BUSTED_ARGS` (F) (U): arguments forwarded to `busted`. + - `GDB` (F) (D): makes nvim instances to be run under `gdbserver`. It will be accessible on `localhost:7777`: use `gdb build/bin/nvim`, type `target remote :7777` inside. |