-
Notifications
You must be signed in to change notification settings - Fork 28
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
System.ArgumentNullException : Value cannot be null #24
Comments
same as #16 but different exception. |
Interesting. Do you happen to have an example of a test which has this error?
which is what I expected. |
Getting this error with netcore 2.1 Xunit for some of my snapper tests in release even when decorating the method with My branch that is already on netcore 3.1 doesn't have the issue so not sure how helpful this is from a debugging perspective but it's more weight to the argument to switch to [CallerMemberName] .
|
Hey @WarrenFerrell, I'm thinking of introducing the concept of passing letting a user pass in a obj.ShouldMatchSnapshot(new SnapshotId(filePath, snapshotName, childSnapshotName); What would you think about that? The benefits of this approach are that it could work for any test framework since there would be no reliance on trying to figure out the class/method name. It lets the user completely decide where and how they want to store their snapshots. The biggest downside for me with using |
That's a very good point about helper methods, that would actually break some of my own tests. For SnapshotIds, I like it There should be some validation around multiple tests calling the same snapshot though. I can easily see this being done intentionally using inlinedata but I would expect one test run to require all runtime references to the same snapshot contain the same value be the same. It would probably be preferrable if the snapshot doesn't get written when there is a conflict so the original snapshot value and the value from every reference will probably need to be stored. |
Good point about conflicts, I didn't consider that. Passing in the snapshot does introduce some problems and limitations. I'm not sure solving for conflicts is worth it though (or even possible). The other limitation of this the snapshot id method is that in some cases the user can't use the I'm now thinking I could release this as an experimental feature until I/someone has a better idea. |
You could pass the SnapshotId via an attribute. That makes the reflective task of finding all methods using SnapshotIds vastly easier. I think it would be nice to be able to have multiple tests call the same snapshot but the initial implementation could forgo that capability as long as it doesn't restrict it from being added later. |
Unfortunately passing it in via attribute won't work. One of the main reasons for implementing this feature is because it's not always possible to to detect which attributes are applied onto the test method when I'll try a bunch of different things and try release this as an experimental feature soonish. It'll have a bunch of limitations but it should solve some problems for some people. |
I figured I would chime in to say I'm running into this same issue with our automated test builds in Azure devops. Adding the |
@theramis do you know why the Null exception is thrown instead of the SupportedTestMethodNotFoundException in TestMethodResolver.cs: 41 . It seems as though the the method is found but stackFrame.GetFileName is returning null. It might be nice to have an exception when this occurs to help figure out what is going on. |
Interesting haven't seen that before. I imagine it can happen when the debug files are not populated enough for it to extract the filename from. The comment here https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackFrame.cs#L154-L163 suggests its extracted from the debug files. You can try adding
to your csproj and see if that fixes the issue. I will update Snapper to catch this exception though and throw |
Sorry about the late response. Yes the Optimize tags has been the only way for me to resolve that exception. Unfortunately it is extremely difficult to reliably reproduce it. Methods that did it before no longer do. |
I've released a fix for this in 2.2.4. |
I know now this error is because
Release
mode, but i think we should handle this more gracefully.The text was updated successfully, but these errors were encountered: