question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TestCase with DataRow attribute with null parameter ignored

See original GitHub issue

Description

When using MSTest.TestAdapter version 2.2.4 or higher, DataRow testcases with a null parameter are not discovered or executed. When using 2.2.3, all 3 testcases are discovered.

[TestMethod]
[DataRow(null)]
[DataRow("")]
[DataRow(" ")]
public void TestMethod(string parameter)
{

}

image

Steps to reproduce

Create a test project targetting .NET5 or .NET6, and make sure the version of the package MSTest.TestAdapter is 2.2.4 or higher. Add test method as seen above

Expected behavior

3 testcases should have been executed, but only the last two are executed

Actual behavior

Only the testcases with “” and " " as paramter are executed

Environment

MSTest.TestAdapter 2.2.4 or higher

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
marnilsscommented, Apr 29, 2022

You need to set TestDataSourceDiscovery to DuringExecution in your test assembly as described here.

@Haplois, surely that is a temporary workaround, not a solution? So why close this issue?

Even though you have changed the implementation of how discovery of tests are done, shouldn’t the new one also be fixed to return the expected amount of testcases? Instead of saying - run the old behavior if you want something that works!!! Because I can’t see, nor has anyone else pointed it out, anything wrong with the sample provided by the TS - so it should work even with new discovery method.

2reactions
notcakecommented, Aug 13, 2022

Sounds like a duplicate of #1016, where test cases get ignored when they have the same display name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MsTest datadriven: ignore specific datarows via testattribute?
How to not let the ignored tests "pass" in the MSTEST testrunner (and in the CI via msbuild), or even better, do not...
Read more >
MsTest v2 DataRowAttribute: null is ignored if last of two ...
Hi, I found a mismatch in the execution of DataRow tests between MsTestRunner and NCrunch. In detail it seems like NCrunch simply ignores...
Read more >
How to test for a not null value for a object property
I'm trying to figure out what the assertion should look like because I want to test to see that the title that was...
Read more >
Java Unit Testing with JUnit and TestNG
A test case contains a number of tests, marked with annotation of " @org.junit.Test ". Each of the test is run independently from...
Read more >
Most Complete MSTest Framework Tutorial Using .Net Core
Marks a method, i.e., an actual test case in the test class. [DataRow], Allows setting the values of the parameters of the test....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found