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

Manipulated TestCaseSource arguments (strings), if they contain apostrophes #90

Open
StarWars999123 opened this issue Dec 15, 2015 · 5 comments
Assignees
Milestone

Comments

@StarWars999123
Copy link

The Nunit test runner can not handle apostrophes in string parameter values. After building the project, the test explorer shows different test cases than expected. Instead of the Input of the TestCaseSource Tim'sHouse you'll see a test EnterTest("Tim\'sHouse").

In my case this completly wastes the important test case, and i'll have to correct the input arguments afterwords in the procedure. It would be great, when the test explorer would not longer add apostrophs to the strings, or at least, if the escapes would be removed, before the test run starts.

string[] myPasswords=new String[] {"Tim'sHouse"};
[Test]
[TestCaseSource("myPasswords")]
public void EnterPassword(string password)
{
      //here the input parameter for password is >>Tim\'sBar<<. 
      Assert.AreEqual("Tim\\'sHouse",password);// (You) Shall not pass!
      Assert.AreEqual(myPasswords[0], password);//This should compare the input value to the input value, however this fails!
}

Do you know any workaround for this case?

Best regards,

StarWars999123

@rprouse
Copy link
Member

rprouse commented Dec 15, 2015

Are you using the original NUnit 2 adapter or the new NUnit 3 adapter?

@StarWars999123
Copy link
Author

The original Nunit 2 Adapter. However, the same issue appears, if I use the Nunit-GUI of the Visual Studio project. I also changed the string to string[] mypasswords=new String[] {@"'"};

However, Nunit (2.6.4.14350) still adds an slash before and discovers the test as EnterPassword("\'")!

@rprouse
Copy link
Member

rprouse commented Dec 16, 2015

Thanks, we will test if this has been fixed in NUnit 3.

On Dec 16, 2015 4:10 AM, StarWars999123 notifications@github.com wrote:

The original Nunit 2 Adapter, however. The same issue appears, if I use the Nunit-GUI of the Visual Studio project. I also changed the string to >>string[] mypasswords=new String[] {@"'"};<<.

However, Nunit (2.6.4.14350) still adds an slash before and discovers the test as >>EnterPassword("'")<<!


Reply to this email directly or view it on GitHub.

@OsirisTerje
Copy link
Member

This error has been fixed in the NUnit3 adapter. It should be trviial to fix this in the the 2. adapter.
Repro solution here https://github.com/OsirisTerje/NUnit.Issues in the Issue90 folder

@OsirisTerje OsirisTerje added this to the 2.2 milestone Dec 28, 2015
@OsirisTerje
Copy link
Member

This comes from the underlying engine, in NUnit3 it is fixed, in NUnit 2.X it is not. We can modify in the adapter but there must be some rule for doing that, we don't want to remove intentional '', but I would assume it would then add double-backslashes,.so the rule can be to delete single backslashes.

@OsirisTerje OsirisTerje self-assigned this Jan 3, 2016
@OsirisTerje OsirisTerje modified the milestones: 2.1, 2.2 Mar 3, 2017
@OsirisTerje OsirisTerje modified the milestones: 2.2, 2.3 Jun 3, 2019
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

4 participants