-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: testify subtests stopped working #275
Comments
Thanks for reporting. Can you please check if func (suite *Suite) TestFoo() {
suite.Run("foo", func() {
// do smth
})
suite.Run("bar", func() {
// do smth other
})
} |
I haven't got the time right now, but if you wish you can try adding a test among the existing testify tests and then modify the queries in https://github.com/fredrikaverpil/neotest-golang/blob/main/lua/neotest-golang/features/testify/lookup.lua that mentions For example, you should be able to do something like this (two occurrences in the file): - operand: (identifier) @suite_lib (#eq? @suite_lib "suite")
+ operand: (identifier) @suite_lib (#match? @suite_lib "^[suite|s]$") |
Hello, thanks for answering. As I can understand these queries, testify/lookup.lua contains queries for parsing like "starter" function for testify, which let standart golang test mechanism start testify suite. My problem is with detecting subtests (e.g. table tests) which are defined in query.lua at the root (almost). |
Ah yes, I think I made a mistake earlier then. I need to dig into this and see what to do. I think I would like to limit the use of |
@uroborosq would you mind giving the {
"fredrikaverpil/neotest-golang",
branch = "testify-operand",
} I think this might work. I just need to add some tests into #280 to verify it. |
@fredrikaverpil ok, thanks I will try in the nearest future |
Yes, it works but only for usual tests like s.Run("foo", func() {
// smth
}) but unfortunately doesn't work for table tests with such structure cases := []testCase{ {name: "foo" ... }}
for _, test := range cases {
s.Run(test.name, func() {
...
}
}
} |
Table tests are not something I ever added support for, when it comes to testify. They are only supported for "vanilla" tests. Are you saying table tests used to work with testify? 🤔 The current testify specific tree-sitter queries would have to be extended to support table tests. I'm open to PRs which would enable this, but I don't plan on implementing this myself, as I don't use testify. |
Table tests had been working good enough until bd8e69e There is no any significant differences between vanilla testing and testify table tests in my opinion, just using suite receiver instead of testing t, so yes, it worked |
Okay, interesting. I can probably re-introduce this behavior fairly simply in that case. It's somewhat funny that all of that was a side effect of having the base treesitter queries mixed with the testify treesitter queries. It's probably a good idea to not mix them and instead have two different set of queries so to avoid future bugs. I'll look into it. |
@uroborosq I added back the table tests support but only for this kind of table tests: func (s *ExampleTestSuite) TestSubTestOperand3() {
tt := []struct {
name string
value int
}{
{
name: "foo",
value: 5,
},
{
name: "bar",
value: 5,
},
{
name: "baz",
value: 5,
},
}
for _, tc := range tt {
s.Run(tc.name, func() {
s.VariableThatShouldStartAtFive = tc.value
assert.Equal(s.T(), 5, s.VariableThatShouldStartAtFive)
})
}
} Maybe you can see if this works for you, by using the There are loads of other ones to copy from the "vanilla" |
@uroborosq take note of that I limited the operand to EDIT: Hmm... I just realized you can't run the nearest test on the |
@uroborosq I'm releasing the initial fix you verified for me. But I'm holding off on the table tests one for now. |
It seems that now it works as it was before from the first look:
Run nearest test is also working for me Speaking about different operands - May be you can do this configurable and leave |
That's nice to hear. Were you referring to the latest v1.9.2 release from today, or the
Hey, that's a great idea, I'll try to do that! |
Did you check docs and existing issues?
Neovim version (nvim -v)
0.10.3
Operating system/version
archlinux
Output from
:checkhealth neotest-golang
Describe the bug
Testify subtests no more detected by neotest, only suites and methods.
Looks like it related to bd8e69e, because usually receiver for suites is
s
, but this fix forbid any other receivers exceptt
If i rename
s
tot
, everything works as expectedSteps To Reproduce
Expected Behavior
Subtests detected with any receiver name
Your Lua setup
The text was updated successfully, but these errors were encountered: