Neovim for Beginners — Testing

Test-driven development (TDD) using Neovim.

alpha2phi
5 min readFeb 26, 2022

--

Neovim for Beginners — Testing

Regardless of programming languages, test-driven development (TDD) is a good practice to follow. For developers to adopt TDD, there are several key criteria.

  • It must be easy to create test cases regardless of which test frameworks.
  • It must be easy to run specific test cases or a suite of test cases.
  • It must be easy to view the test summary and report.
  • It must be easy to debug failed test cases.

In this article, we are going to

  • Configure test plugins for Neovim.
  • Configure code snippets plugins and use them to create test cases.
  • Run specific test cases, or all test cases, and view the summary.
  • Debug failed test cases.
  • Configure automated test cases for a web application.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.

This article is part 1 of the following articles related to testing.

Setup

We are going to install the vim-test and vim-ultest plugins.

In the lua/plugins.lua file, add the lines to install the plugins.

We configure both plugins as optional and they are loaded only when certain commands and keys are triggered. Check out the plugin management article for more details.

Configuration File

Create the lua/config/test.lua file with the following content.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.