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

Problems with null in DataRow #70

Closed
codito opened this issue Feb 12, 2017 · 0 comments
Closed

Problems with null in DataRow #70

codito opened this issue Feb 12, 2017 · 0 comments
Assignees
Milestone

Comments

@codito
Copy link
Contributor

codito commented Feb 12, 2017

Copied from microsoft/vstest#471 on behalf of @jmagaram

Description

Occasionally my unit tests fail to run and display a very cryptic message in the output. I've narrowed the problem down to using null values inside a DataRow. The error message is completely unhelpful and the fix is unexpected. I can't believe this is by-design.

[DataTestMethod]
[DataRow(false, "abc")]
[DataRow(true, "")]
[DataRow(true, "   ")]
[DataRow(true, null)]
public void IsStringNullOrWhitespace(bool expectedResult, string s)
{
    bool result = String.IsNullOrWhiteSpace(s);
    Assert.AreEqual(expectedResult, result);
}

The error message is Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.

The "fix" is to replace the last row with...

[DataRow(true, (string)null)]

When I do this, Visual Studio recommends removing the unnecessary cast. I've tried labeling the datarow parameters but can't seem to make this work.

Steps to reproduce

Try running the unit test above in the RC version of Visual Studio 2017.

Expected behavior

I expect the test to run and give me correct results. Or a much more helpful error message.

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

2 participants