nvim-neotest / neotest-go

MIT License
124 stars 43 forks source link

Running package tests #58

Closed jstensland closed 5 months ago

jstensland commented 10 months ago

I'm not sure if this is a feature request or a question, but I can't seem to run a single go package's tests. Trying to pass a folder looks like it results in changing to that directory and running the tests for all sub folders, a command like

cd ./target/package && go test -v -json ./...

But I want something more like

go test -v -json ./target/package

or cd and then use .

The Usage > Test file in the README does the same thing.

sergii4 commented 9 months ago

Hi @jstensland, I am not sure I understand the problem. How is related to the plugin? What's steps to reproduce?

jstensland commented 9 months ago

Sorry if I'm not clear. I'll try again. Overall, is it possible to run a single package's tests? If you have a folder structure like

pkg1
├── subpkg2
│   ├── file3.go
│   ├── file3_test.go
│   └── export_test.go
├── file1.go
├── file1_test.go
├── file2.go
└── file2_test.go

Is there a neotest command I can run that will run the tests in pkg1/file1_test.go and pkg1/file2_test.go but not those in pkg1/subpkg2/file3_test.go?

Steps to reproduce would be to set up such a structure. Include a failing or broken test in subpkg2, and then try do: require('neotest').run.run("pkg1"). Expected result would be a pass for pkg1, but instead you get failures from subpkg2

It is running both pkg1 tests and subpkg2 tests. See my first comment for the type of final command it ends up running, with the ./... that catches all sub folders.

nieomylnieja commented 8 months ago

Up. We should stick to the behaviour of go test and not recurse a directory unless a glob pattern is provided.

sergii4 commented 7 months ago

You are right, folks. I am working on PR