nunit3-vs-adapter: Incorrect format for TestCaseFilter Error: Missing '('
Environment
- NUnit 3.12
- NUnit Adapter 3.16
- VS Professional 2019 Version 16.4.2
- .NET Framework 4.7.2
Description When executing a category of tests (e.g. Run All), if a test is included in the list of tests that contains an escaped double quote followed by a closing parenthesis, the following error may occur and the test run will fail:
An exception occurred while invoking executor ‘executor://nunit3testexecutor/’: Incorrect format for TestCaseFilter Error: Missing ‘(’.
Note There are a number of recently closed issues (thanks 😃 ) that are similar regarding braces or quotes in the test case name or arguments, but this is not quite the same (esp. since it breaks despite resolution of the other issues)
Reproduction Run this code, and examine the Test Output window to see the exception as per above.
public class Tests
{
[TestCase("Works fine", ")")]
[TestCase("Works fine", "()")]
[TestCase("Works fine", "(")]
[TestCase("Works fine", "\"(")]
[TestCase("Works fine", ")\"")]
[TestCase("Works fine", "(\"")]
[TestCase("Works fine", "()\"")]
[TestCase("Breaks test executor when using Run All", "\"()")]
[TestCase("Breaks test executor when using Run All", "\")")]
public void TestName(string expectedBehaviour, string data)
{
//Irrelevant
}
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 16
- Comments: 33 (10 by maintainers)
Commits related to this issue
- repro for https://github.com/nunit/nunit3-vs-adapter/issues/691 — committed to mikhail-barg/jsonata.net.native by mikhail-barg 3 years ago
- repro for https://github.com/nunit/nunit3-vs-adapter/issues/691 — committed to mikhail-barg/jsonata.net.native by mikhail-barg 3 years ago
- Tests are crashing due to NUnit bug: https://github.com/nunit/nunit3-vs-adapter/issues/691 Nunit bug is that InlineData in strings need to have balanced quotes. Update test case. This shouldn't lose c... — committed to microsoft/Power-Fx by deleted user 2 years ago
A workaround for fellow developers / testers who just want to make the tests run again: Wrap your test case data in a
TestCaseDataobject, and return with anIEnumerable<TestCaseData>instead of anIEnumerable<object[]>. Fill theTestNameof each of these cases; avoid special characters, and “tadaa” the tests will run again properly.// Still looking forward to a proper fix though.
I’m getting this error with the latest packages (for vs2019) running in vs 2022:
I’ve created a gist with the relevant files I can think of: https://gist.github.com/redwyre/0fb0c9f177af278f76aa8cf49c1eb1dc
It seems like NUnit is just calling ToString() on all the parameters to make the test name, and in some cases it doesn’t work properly with more complex objects.
I think I can work around this by wrapping each record in
TestCaseDataand name them, but it overrides the full name of the test not just the postfix. I’m not very experienced with NUnit myself so not sure if there is a better way.Thanks! We’re aware of these cases too, but thanks for the test code!
There are even more bizarre behavior here. I added some more with explanations at https://github.com/nunit/nunit3-vs-adapter.issues/tree/master/Issue691/Issue691
Part of this is a Visual Studio issue, part of it is the name handling in the adapter - and these things are not properly aligned yet.
@mikhail-barg Thanks for checking this out 😃
Updated all packages in Issue691.sln to latest versions, and still everything work:
Yes, I think so. Will double-check and try to create a repro
Same issue happening with nunit test adapter v 3.17.0.0.
Thanks for the response & update.
I can confirm that I’m also getting test explorer issues as described in issue 691, as well as general issues with test explorer being glitchy and not updating status from the nunit test run.
This is why I cringe every time I update something that works 😢 (VS in this case)