If you're keen on TDD, then leaving your editor to run tests can be annoying. There are lots of options for running tests, however: some people use file watchers to trigger tests when the project's files are modified, and others use test runners from within their IDE or editor. Janko Marohnić sent in test.vim, which is a new plugin for triggering test runners.
Janko wanted features like zero dependencies and configuration, automatically choosing the correct test runner, and a wide range of language/platform support. Lots of Vim test runners are Ruby-focused, which makes sense because the Ruby community is big on testing. However, the exact way in which a single test, test file, or test suite is actually run is highly dependent on each test framework.
The way test.vim works is to associate test runners with strategies. It has to be able to do the right thing for running a test nearest the current line of code (
:TestNearest), running the current test file (
:TestFile), or running the entire suite (
Let's look at a non-Ruby example. The gotest.vim file has a function that uses regular expressions to find the nearest test for the current line (
'\v^\s*func \zs\w+'), and it defines the test executable as
go test. It matches test files by using the convention