Unit Test

Introduction

Unit tests are embedded into the codebase, usually placed next to the logic being tested. They are written using Rust’s #[test] attribute and can run with cargo nextest run.

The default test runner ships with cargo is not supported in GreptimeDB codebase. It’s recommended to use nextest instead. You can install it with

  1. cargo install cargo-nextest --locked

And run the tests (here the --workspace is not necessary)

  1. cargo nextest run

Notes if your Rust is installed via rustup, be sure to install nextest with cargo rather than the package manager like homebrew. Otherwise it will mess up your local environment.

Coverage

Our continuous integration (CI) jobs have a “coverage checking” step. It will report how many codes are covered by unit tests. Please add the necessary unit test to your patch.