-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fix NullReferenceException in tests #139
Fix NullReferenceException in tests #139
Conversation
If multiple unit tests are running in parallel, it is possible for the Add() operation on the dictionary to throw a NullReferenceException internally and cause a test to fail. Fix this by using ConcurrentDictionary instead.
How are you able to reproduce this I'm using NCrunch's churn mode to try to reproduce this test running |
I just use the Visual Studio Test Explorer. I right click on the This is from the |
So a sure fire way for me to reproduce this is to run all three test namespaces once with the Test Explorer. |
That happened for me on the current master |
Must be an implicit dependency between the suites doing stuff with the trees, plus the default xunit level of parallelism is to run test assemblies against each other in parallel. |
So now i'm testing this pull request using the same means as above, and I'm able to push it to a different race condition. @martincostello wanna see if you can repro/fix this? |
Interesting - I didn't get that one. I'll take a look in a bit and see if I can make that case behave too. |
Prevent sourceExpression being changed between initialisation and assignment.
@StanleyGoldman Want to pull the latest commit and give that a try? |
I'm unable to get it to crash with these changes. Good 💩. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @martincostello!
If multiple unit tests are running in parallel, it is possible for the
Add()
operation on the dictionary to throw aNullReferenceException
internally and cause a test to fail.Fix this by using
ConcurrentDictionary
instead.Originally part of #131.