/neotest-scala

Primary LanguageLuaMIT LicenseMIT

neotest-scala

Neotest adapter for scala. Supports utest, munit and ScalaTest test frameworks, by either running it with bloop or sbt. Note that for ScalaTest the only supported style is FunSuite for now.

It also supports debugging tests with nvim-dap (requires nvim-metals). You can debug individual test cases as well, but note that utest framework doesn't support this because it doesn't implement sbt.testing.TestSelector. To run tests with debugger pass strategy = "dap" when running neotest:

require('neotest').run.run({strategy = 'dap'})

Requires nvim-treesitter and the parser for scala.

Installation

Using packer.nvim:

use({
  "nvim-neotest/neotest",
  requires = {
    ...,
    "stevanmilic/neotest-scala",
  }
  config = function()
    require("neotest").setup({
      ...,
      adapters = {
        require("neotest-scala"),
      }
    })
  end
})

Configuration

You can set optional arguments to the setup function:

require("neotest").setup({
  adapters = {
    require("neotest-scala")({
        -- Command line arguments for runner
        -- Can also be a function to return dynamic values
        args = {"--no-color"},
        -- Runner to use. Will use bloop by default.
        -- Can be a function to return dynamic value.
        -- For backwards compatibility, it also tries to read the vim-test scala config.
        -- Possibly values bloop|sbt.
        runner = "bloop",
        -- Test framework to use. Will use utest by default.
        -- Can be a function to return dynamic value.
        -- Possibly values utest|munit|scalatest.
        framework = "utest",
    })
  }
})

Roadmap

To be implemented:

  • Displaying errors in diagnostics