How to ignore particular test case (DataRow)
See original GitHub issueDescription
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:
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:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
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.