Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

tools for testing vim plugins

I'm looking for some tools for testing vim scripts. Either vim scripts that

  • do unit/functional testing, or
  • classes for some other library (eg Python's unittest module) that make it convenient to
    • run vim with parameters that cause it to do some tests on its environment, and
    • determine from the output whether or not a given test passed.

I'm aware of a couple of vim scripts that do unit testing, but they're sort of vaguely documented and may or may not actually be useful:

vim-unit:

  • purports "To provide vim scripts with a simple unit testing framework and tools"
  • first and only version (v0.1) was released in 2004
  • documentation doesn't mention whether or not it works reliably, other than to state that it is "fare [sic] from finished".

unit-test.vim:

  • This one also seems pretty experimental, and may not be particularly reliable.
  • May have been abandoned or back-shelved: last commit was in 2009-11 (> 6 months ago)
  • No tagged revisions have been created (ie no releases)

So information from people who are using one of those two existent modules, and/or links to other, more clearly usable, options, are very welcome.

question from:https://stackoverflow.com/questions/3029882/tools-for-testing-vim-plugins

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

vader.vim is easy, and amazing. It has no external dependencies (doesn't require ruby/rake), it's a pure vimscript plugin. Here's a fully specified test:

Given (description of test):
  foo bar baz

Do (move around, insert some text):
  2Wiab<Enter>c

Expect:
  foo bar ab
  cbaz

If you have the test file open, you can run it like this:

:Vader %

Or you can point to the file path:

:Vader ./test.vader

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...