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.

How to ignore particular test case (DataRow)

See original GitHub issue

Description

I am trying to ignore one test case by adding Ignore keyword for DataRow attribute:

[TestClass]
public class MathTests
{
    [TestMethod]
    [DataRow(1, 1, 2)]
    [DataRow(2, 2, 3), Ignore]
    public void Sum_Test(int a, int b, int expectedSum)
    {
        var sut = new Math();
        
        var sum = sut.Sum(a, b);
        
        Assert.IsTrue(sum == expectedSum);
    }
}

public class Math
{
    public int Sum(int a, int b)
    {
        return a + b;
    }
}

but it ignores the whole test:

image

I also asked this on StackOverflow: How to ignore particular test case in MSTest.

Expected behavior

Only Sum_Test(2,2,3) test case should be ignored.

Actual behavior

It ignores both test cases.

Environment

  • Operating system: Windows 10 Pro
  • Target: .NET 6
  • MSTest.TestFramework: v2.2.8

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Evangelinkcommented, Jan 28, 2023

@adamshakhabov it perfectly makes sense and you are not the only team with such rule. I just wanted to confirm the intent so we could think about how to implement it.

0reactions
BennCowenRTcommented, Apr 20, 2023

We have failing test cases we’d like to ignore with messages indicating ticket number for resolution of the issues. We’d like to ignore rather than comment to maintain visibility of them in our test reporting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create Data-Driven Unit Tests - Visual Studio (Windows)
Use TestContext.DataRow to access the data. To access the data in the AddIntegersData table, use the TestContext.DataRow indexer. DataRow ...
Read more >
Writing parameterised unit tests in C# | by Jamie Burns - Medium
We can parameterise it like this: Note that the [Test] attribute has been replaced with the individual [TestCase] attributes with the inputs ...
Read more >
Stop requiring only one assertion per unit test
We should assert that as well. It's still the same test case, though: Successfully cancelling a reservation. There's nothing wrong with multiple ...
Read more >
Most Complete MSTest Unit Testing Framework Cheat Sheet
[Ignore]. [Fact(Skip="reason")]. Ignores a test case. [Property]. [TestProperty]. [Trait]. Sets arbitrary metadata on a test. [Theory]. [DataRow]. [Theory].
Read more >
Programmatically skip / ignore tests in MSTest v2
This method is aware that on Windows, paths are by default case-insensitive, whereas on Linux and macOS, paths are case sensitive, and adjusts ......
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