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

MS Test data driven tests fail if data param contains null #178

Open
aaronpowell opened this issue Apr 21, 2023 · 0 comments
Open

MS Test data driven tests fail if data param contains null #178

aaronpowell opened this issue Apr 21, 2023 · 0 comments

Comments

@aaronpowell
Copy link
Contributor

Describe the bug
If the DataRowAttribute has a null parameters in it, Snapshooter will error trying to generate the snapshot name.

To Reproduce
Create a MS Test like so:

[DataTestMethod]
[DataRow("str", null)]
public void TestWithNull(string str, string? nullableStr) {
  var data = new { str, nullableStr };
  Snapshoot.Match(data);
}

This results in the following error:

  Message: 
Test method Cli.Tests.InitTests.EnsureCorrectConfigGenerationWithDifferentAuthenticationProviders threw exception: 
System.NullReferenceException: Object reference not set to an instance of an object.

  Stack Trace: 
<>c.<GetMethodSnapshotName>b__6_0(Object d)
SelectArrayIterator`2.MoveNext()
String.Join(String separator, IEnumerable`1 values)
MSTestSnapshotFullNameReader.GetMethodSnapshotName(MethodBase method)
MSTestSnapshotFullNameReader.ReadSnapshotFullName()
SnapshotFullNameResolver.ResolveSnapshotFullName(String snapshotName, String snapshotNameExtension)
Snapshooter.ResolveSnapshotFullName(String snapshotName, SnapshotNameExtension snapshotNameExtension)
Snapshot.FullName()
Snapshot.Match(Object currentResult, Func`2 matchOptions)
Snapshot.Match[T](T currentResult, Func`2 matchOptions)

Expected behavior
Test to pass.

Desktop (please complete the following information):

  • OS: Windows
  • Version 0.13.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant