Home

Awesome

Neotest Bazel

A Neotest adapter to run tests with Bazel.

image

Table of Contents

Installation

With 💤 Lazy.nvim

return {
  {
    "nvim-neotest/neotest",
    dependencies = {
      -- Neotest dependencies
      "nvim-neotest/nvim-nio",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
      -- Our adapter
      "sluongng/neotest-bazel",
    },
    config = function()
      require("neotest").setup({
        adapters = {
          -- Our adapter registration
          require("neotest-bazel"),
        },
      })
    end,
  },
}

Scope

Current supported languages:

I also plan to add more configuration options to help customize Bazel runs.

Users should use .bazelrc and (optional) user.bazelrc to customize their Bazel runs as much as possible in the meantime.

Contributions are welcome!

FAQs

I am coming from Bazel, what is this?

Neotest is a test runner for Neovim that allows you to run tests from within Neovim editor. It exposes a simple interface which we can implement to customize how tests are detected and executed and how the results are parsed and displayed.

This enables us to use Tree Sitter to detect tests granularly (e.g. test files, classess, functions, sub-tests, etc.). We can also use Bazel to detect which test target to run, and which test filter to apply to that run. This adapter also handles parsing of the test.xml and test.log files generated by Bazel so we can review them within Neovim.

Why should I use this instead of neotest-{$language}?

If you are using Bazel in your project to run your tests, this adapter will allow you to run your tests with Bazel. Running tests with Bazel has many advantages, such as accurate test caching and parallel test execution.

With the right setup, you can also run all your build and test in parallel remotely on a compute farm. This massively speed up the iteration speed of your development cycle.

Big organizations like Google, Uber, and Dropbox use Bazel to build and test their massive codebases because it's a matured and reliable build system.

Current Known Issues

Acknowledgements