nvim-neotest / neotest-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running test suite doesn't work

fredrikaverpil opened this issue · comments

The readme states that you can run the full test suite with require('neotest').run.run(vim.fn.getcwd()) if your project root (with go.mod/go.sum in its root) is the current working directory.

Reproduce

  1. Clone down this repo: https://github.com/fredrikaverpil/go-playground
  2. cd lwgt
  3. Start neovim: nvim.
  4. Open test summary: :lua require("neotest").summary.open()
  5. Run :lua require('neotest').run.run(vim.fn.getcwd())
  6. See how no tests are being run. If checking the :Neotest output-panel, it says no Go files in /Users/fredrik/code/public/go-playground/lgwt.

For some other projects, I get a different error in the output, like e.g. package github.com/uuu/xxx/yyy: build constraints exclude all Go files in /Users/fredrik/code/work/private/xxx/yyy.

Workaround

If you add a dummy test file in the root of the project, the tests look like they all execute (in e.g. the test summary), but they actually don't execute.

// dummy test file: t_test.go

package main

import "testing"

func TestDummy(*testing.T) {
}

If you also pass recursive_run = true as option to neotest-go, tests will execute.

require("neotest").setup({
  adapters = {
    require("neotest-go")({
      recursive_run = true
    })
  }
})