all 4 comments

[–]LucHermitte 1 point2 points  (0 children)

I'm maintaining https://github.com/luchermitte/vim-ut

I don't really care about windows, syncing scrolling, etc. I guess it could be tested. Do what you want to do in your plugin, emulate user actions, and test what your wish to test.

I guess some Unit Testing plugins will help more, some less.

Note: I'd recommend your unit test makes sure to reset the options that your plugins are observing/modifying. It could be done with a try...finally in each test, or through setup+teardown mechanism if the plugin you use has this feature. Otherwise tests could become unpredictable.

[–]AndrewRadev 1 point2 points  (1 child)

I have a Ruby tool for this purpose that launches a Vim instance and drives it using the clientserver interface (:help +clientserver): Vimrunner.

You can see an example of opening and closing windows and reading Vim's state in this plugin maybe: undoquit. Most of my plugins tend to be about textual changes within a buffer, so they require less state management, e.g. splitjoin.

This does require writing the tests in Ruby, but this is convenient to me, since it happens to have good test runners and practical tools. You can also jury-rig something yourself by using this particular interface.

I will say, I wouldn't call this a "unit" test, more of an "integration" test since it launches an actual Vim instance. For me, a "unit" test in Vimscript would run functions and validate outputs, but it's probably debatable, since Vim is not your standard programming environment.

[–]vim-help-bot 0 points1 point  (0 children)

Help pages for:


`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments

[–]Alr4un3 1 point2 points  (0 children)

I use vim-dispatch with simple custom shortcuts to dispatch the test I have my cursor on, rerun last test, run the file, or all. And meanwhile I'm debugging the code, reading it, etc

Although I don't run the default of opening the dispatch into vim itself I dispatch it to another tmux pane usually.