Neovim PDE — Test-driven Development

Configure a test-driven development (TDD) environment for manual and automated testing.

alpha2phi
5 min readMay 25

--

Neovim PDE — Test-driven Development

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 and vim-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 that vim-test supports.
  • We also install and configure vim-test which is required by neotest-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 = {…

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.

Recommended from Medium

Lists

See more recommendations