-
Notifications
You must be signed in to change notification settings - Fork 748
NullReferenceException using Is.EqualTo on two unequal strings #2025
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
Comments
It seems that it is more likely that somewhere in your chain is a null.
That is working for me. |
Yeah the code snippet you posted works fine it only throws the NullReferenceException when the strings don't match and only on 3.6.0. |
What nunit adapter version are you using? |
Hmmm I'm not using the NUnit Adapter package just the framework package, do I need the adapter package? |
FYI I just got the same issue again but this time testing equality of two doubles. Seems it happens whenever the objects aren't equal. |
No need for the adapter if that's not how you are running your tests. How are you running them? Is this happening in an async method? Or in a thread created by your test? |
Using Specflow and Specrunner to run the tests. I'm not creating an Async method so presumably it's a thread created by my test. |
Presumably? Either you have code to create a thread or you don't. 😄 Can you run the tests with nunit3-console? |
Sorry I've been writing automated tests for two weeks so a lot of the concepts are still new to me. I'm not explicitly creating threads. Tests are just being run via specflow feature files, I don't know how specflow handles threads. As for the nunit3 console, I don't know how, will need to look into it. |
OK, as another approach to this, can you post the stack trace from the exception? I'm suspecting this is related to another bug report. |
Unfortunately, most of us who write NUnit know even less about. SpecFlow than you. 😄 |
Here you go, changed the filepath for client confidentiality reasons but everything is as is: at NUnit.Framework.Assert.ReportFailure(String message) |
Does SpecFlow+ work with NUnit 3.6? I am looking at the free version and it installs something like version 3.0.0 and it seems to generate the test.dll and runs it through the nunit-console. At the moment, I can't seem to find how do they write the test fixtures. |
SpecFlow Generated Test Fixture.txt The TestRunner runs on it's own thread. |
Recreated the issue again in v3.6.0 and then retested in v3.6.1 of the NUnit framework with the same code and it is now working as expected. Thanks for the assistance Charlie. |
I'm writing some tests and wanted to test the equality of two strings. I didn't realise until runtime that they would be unequal. I expected the Assert to fail but not with a null reference exception.
Text comparison as been shortened for ease of reading but the result is the same.
At runtime errorText = "Oops!\r\nYou can only book one infant per adult online.".
If I change requiredText to "Oops!\r\nYou can only book one infant per adult online." it works without an exception.
This Exception is only thrown on v3.6.0, If I try the same Assert on earlier versions it works fine so I'm trying to determine if it's a feature or an issue.
I can get around the issue by using Does.Contain but have been asked by my organisation to see if we can identify the cause of this unexpected exception.
Let me know if I need to provide any more information, I'm fairly new to automation testing.
The text was updated successfully, but these errors were encountered: