Skip to content
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

Invalid characters in test name breaks test runner #549

Closed
laura-campbell opened this issue Sep 27, 2018 · 8 comments
Closed

Invalid characters in test name breaks test runner #549

laura-campbell opened this issue Sep 27, 2018 · 8 comments

Comments

@laura-campbell
Copy link

  • versions: NUnit 3.0 and NUnit Adapter 3.10.0.21

  • Visual Studio Professional version 15.8.5

  • .NET framework is 4.6.1

  • When a test with a custom name has invalid characters in that name (in this case, '&'), the nunit adapter throws an error and the tests are removed from the window

  • Only appears to happen when you select a group of tests

  • Doesn't appear to happen on other machines

  • repro: https://github.com/laura-campbell/nunit3bug

public class Class1
{
        [TestCaseSource("testcases")]
        public void foo()
        {
        }
        public static IEnumerable<TestCaseData> testcases { get; } = new[] { new TestCaseData().SetName("&") };
}

image
test is visible after building the solution

image
chose to run selected tests on a group of tests

image
test is not run and disappears from the window

Error message:

[9/27/2018 11:47:55 AM Error] An exception occurred while invoking executor 'executor://nunit3testexecutor/': Incorrect format for TestCaseFilter Error: Missing operand. Specify the correct format and try again. Note that the incorrect format can lead to no test getting executed.
@rprouse
Copy link
Member

rprouse commented Sep 27, 2018

Thanks, looks like a problem parsing the filters that are sent from the test window to the adapter. Does it happen if the test name is more than just &, for exampe apples&pears?

@benjamin-hodgson
Copy link

benjamin-hodgson commented Sep 27, 2018

Does it happen if the test name is more than just &, for exampe apples&pears?

Yes it does. (We first encountered it in a test whose name contained a URL with a query string.) The error message is different but I'm confident that it's the same bug.

@rprouse
Copy link
Member

rprouse commented Sep 27, 2018

Excellent, thanks. That will increase the priority then, especially since & is used in URI query params as you mentioned.

@aboldock
Copy link

we are also seeing this problem with 3.10.0.21 with # in the test name and the tests being source from a paramaterised set eg: [Test, TestCaseSource(typeof(AdtPatientTestDataFactory), "TestCases")]
strange thing is not all our devs are seeing the problemonly some, we have changed all our test names to get around this issue on some machines.

@LangdalP
Copy link

LangdalP commented May 21, 2019

I am having the same type of problems. I am from Norway, and in our project we use Norwegian test names. This means that the names may contain æøå and ÆØÅ, which breaks the adapter. We have over a thousand tests, and I don't want to start renaming all of them because of this, so currently I am using the console test runner instead.

Edit: I might have been wrong about æøå breaking the test runner. It was more likely some special characters in the test input data (an "&" for instance).

@Macht59
Copy link

Macht59 commented Aug 1, 2019

I have the same problem - just me and non of my colleges.
In my case the error caused by character '='. Replacing '=' characted with 'equals to' resolved the problem.

@johnmwright
Copy link
Contributor

This issue has the same underlying cause as #622 and is resolved by PR #668

@OsirisTerje OsirisTerje added this to the 3.16 milestone Oct 31, 2019
@OsirisTerje
Copy link
Member

@laura-campbell @Macht59 @benjamin-hodgson @LangdalP @aboldock
Checking 3.16.0-dev on this one. To make it work, NUnit also has to be on Version 3.12.
https://www.myget.org/feed/nunit/package/nuget/NUnit3TestAdapter/3.16.0-dev-01202

Before:
image

After only adapter upgrade:
image

After adapter AND NUnit upgrade:
image

All tested with VS 2019 , 16.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants