blob: 7aa185f0a81bfd8afc23869b40d8f9b0f0b2d15e [file] [log] [blame]
Bram Moolenaara9537d22014-08-29 10:04:47 +02001This directory contains tests for various Vim features.
2
Bram Moolenaar6602af72016-01-07 22:01:01 +01003If it makes sense, add a new test method to an already existing file. You may
4want to separate it from other tests with comment lines.
Bram Moolenaara9537d22014-08-29 10:04:47 +02005
Bram Moolenaar9e4d8212016-08-18 23:04:48 +02006The numbered tests are older, we have switched to named tests. Don't add any
7more numbered tests.
Bram Moolenaara9537d22014-08-29 10:04:47 +02008
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02009And then you can choose between a new style test, which is a Vim script, or an
Bram Moolenaar6602af72016-01-07 22:01:01 +010010old style test, which uses Normal mode commands. Use a new style test if you
Bram Moolenaar9e4d8212016-08-18 23:04:48 +020011can. Use an old style test when it needs to run without the +eval feature.
Bram Moolenaar6602af72016-01-07 22:01:01 +010012
13
14TO ADD A NEW STYLE TEST:
15
161) Create a test_<subject>.vim file.
Bram Moolenaarcaa55b62017-01-10 13:51:09 +0100172) Add test_<subject>.res to NEW_TESTS in Make_all.mak in alphabetical order.
183) Also add an entry in src/Makefile.
194) Use make test_<subject>.res to run a single test in src/testdir/.
Bram Moolenaar6602af72016-01-07 22:01:01 +010020 Use make test_<subject> to run a single test in src/.
Bram Moolenaara9537d22014-08-29 10:04:47 +020021
Bram Moolenaar6602af72016-01-07 22:01:01 +010022What you can use (see test_assert.vim for an example):
Bram Moolenaardac19472016-09-03 22:35:40 +020023- Call assert_equal(), assert_true(), assert_false(), etc.
Bram Moolenaar6602af72016-01-07 22:01:01 +010024- Use try/catch to check for exceptions.
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +020025- Use alloc_fail() to have memory allocation fail. This makes it possible
Bram Moolenaar6602af72016-01-07 22:01:01 +010026 to check memory allocation failures are handled gracefully. You need to
27 change the source code to add an ID to the allocation. Update LAST_ID_USED
28 above alloc_id() to the highest ID used.
Bram Moolenaar2ab375e2016-02-10 22:23:06 +010029- Use disable_char_avail_for_testing(1) if char_avail() must return FALSE for
30 a while. E.g. to trigger the CursorMovedI autocommand event.
31 See test_cursor_func.vim for an example
Bram Moolenaardac19472016-09-03 22:35:40 +020032- If the bug that is being tested isn't fixed yet, you can throw an exception
33 so that it's clear this still needs work. E.g.:
34 throw "Skipped: Bug with <c-e> and popupmenu not fixed yet"
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +020035- See the start of runtest.vim for more help.
Bram Moolenaar6602af72016-01-07 22:01:01 +010036
37
Bram Moolenaarda650582018-02-20 15:51:40 +010038TO ADD A SCREEN DUMP TEST:
39
40Mostly the same as writing a new style test. Additonally, see help on
41"terminal-dumptest". Put the reference dump in "dumps/Test_func_name.dump".
42
43
Bram Moolenaar6602af72016-01-07 22:01:01 +010044TO ADD AN OLD STYLE TEST:
45
461) Create test_<subject>.in and test_<subject>.ok files.
472) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order.
483) Use make test_<subject>.out to run a single test in src/testdir/.
49 Use make test_<subject> to run a single test in src/.
504) Also add an entry in src/Makefile.
51
52Keep in mind that the files are used as if everything was typed:
53- To add comments use: :" (that's an Ex command comment)
54- A line break is like pressing Enter. If that happens on the last line
55 you'll hear a beep!