Neovim PDE — Test-driven Development
Configure a test-driven development (TDD) environment for manual and automated testing.
In this article, we will set up a test-driven development environment for different programming languages.
This article is part of the Neovim PDE series.
The Neovim configuration files are available in this repository.
Getting Started
Neovim is a great choice for practicing test-driven development (TDD) in our programming workflow. TDD is an approach where we write tests before writing the actual code, and Neovim provides features that can support this process.
We have already set up the development environments for Lua, Python, Go, Rust, C/C++, and Java. Before proceeding, we will configure a test-driven development environment for these languages.
Test-driven Development Environment
Common Configuration
We install the plugins and set up the common configuration in the lua/base/coding.lua
file.
- For testing, we will use the
neotest
andvim-test
plugins. - We configure
neotest
with its dependencies (line 28 — line 36). - We configure the keymappings for testing (line 37 — line 48).
- We use the
neotest-vim-test
adapter for languages without any test adapter (line 51 — line 55). It supports any runner thatvim-test
supports. - We also install and configure
vim-test
which is required byneotest-vim-test
(line 11 — line 26).
With this common setup, we can proceed to configure the testing environment for those programming languages we want to use.
Lua
In the lua/pde/lua.lua
file, we add the following lines to support Lua testing.
{
"nvim-neotest/neotest",
dependencies = {…