Skip to content

olisikh/neotest-scala-backup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

neotest-scala

Neotest adapter for scala.

Supports the following Scala testing libraries:

Runs tests with bloop or sbt.
Relies on nvim-metals to get project metadata information

Hero image

Debugging

Plugin 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'})

Requirements

  • nvim-treesitter and the parser for scala.
  • nvim-metals has no direct hard dependency, but relies on Metals LSP client to get metadata about the project.

Missing features:

  • diagnostics (only specs2)
  • only FunSuite and FreeSpec are supported in scalatest
  • only mutable.Specification style is supported in specs2

Installation

Using packer.nvim:

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

Configuration

You may override some arguments that are passed into the build tool when you are running tests:

require("neotest").setup({
  adapters = {
    require("neotest-scala")({
      args = {"--no-color" },
    })
  }
})

If you are using both Bloop an SBT in your projects, you may want to dynamically specify args:

require("neotest").setup({
  adapters = {
    require("neotest-scala")({
      args = function(opts)
        local my_args = {}

        if opts.runner == "sbt" then
          -- example: don't add ANSI colors in SBT
          table.insert(my_args,  "--no-colors")
        elseif opts.runner == "bloop" then
          -- example: don't add ANSI colors if using bloop, bloop expects '--no-color' argument
          table.insert(my_args, "--no-color")
        end

        if opts.path == "/my/absolute/path" then
          -- path is the folder where build.sbt resides
        end

        if opts.framework == "specs2" then
          -- framework value can be 'munit', 'utest', 'scalatest', 'specs2'
        end

        if opts.project == "my-secret-project" then
          -- project name (build target)
        end

        return my_args
      end,
    })
  }
})

Roadmap

To be implemented:

  • Detect test library
  • Detect build tool that is being used
  • Display errors in diagnostics (only specs2 is supported for now)
  • Don't block neovim when trying to figure out the project name for building test commands

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 92.8%
  • Scala 7.2%