Extra test cases for DataRow methods
See original GitHub issueDescription
After upgrading MSTest to MSTest v2, there is an extra test case for each DataRow method (like a summary to all data row tests of the method). And that causes the number of total tests, passed and failed are also not expected. It is fine with MSTest v1 and vstest.cosole.exe.
Is this a known issue or expected feature? Is there any parameters can be set to change the behavior?
Steps to reproduce
[DataTestMethod]
[DataRow("1")]
[DataRow("2")]
public void TestMethodA(string a)
{
Assert.IsTrue(true);
}
[DataTestMethod]
[DataRow("1")]
[DataRow("2")]
public void TestMethodB(string a)
{
Assert.IsTrue(a.Equals("1"));
}
Expected behavior
Passed TestMethodA (Data Row 0)
Passed TestMethodA (Data Row 1)
Passed TestMethodB (Data Row 0)
Failed TestMethodB (Data Row 1)
Total tests: 4. Passed: 3. Failed: 1. Skipped: 0.
Actual behavior
Passed TestMethodA
Passed TestMethodA (Data Row 0)
Passed TestMethodA (Data Row 1)
Failed TestMethodB
Passed TestMethodB (Data Row 0)
Failed TestMethodB (Data Row 1)
Total tests: 6. Passed: 4. Failed: 2. Skipped: 0.
Environment
Run tests through vstest.console.exe
on Azure DevOps
MSTest 1.3.2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:48 (23 by maintainers)
Top Results From Across the Web
Improving MSTest unit tests with DataRows
Our first option for testing would be to write a series of tests that ... This is better, but it comes at the...
Read more >Create Data-Driven Unit Tests - Visual Studio (Windows)
Learn how to use the Microsoft unit test framework for managed code to set up a unit test method to retrieve values from...
Read more >Writing parameterized unit tests in C# — Run the same test ...
One of the best ways to do that is to write a single test which will support multiple test cases through parameters. This...
Read more >Using DataTestMethod and DataRow to pass parameters to a ...
In TDD, you will need to test for various inputs based on some condition. For example, we have a class that is responsible...
Read more >Running selective unit tests with specific DataRow Value - ...
I would try first to use the .runsettings method for defining environment variables for running tests: ...
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 FreeTop 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
Top GitHub Comments
2.2.8, works totally fine for me
I’d like to argue that this is a bug and undesired behavior!
It seems that not only the results seem off. It also seems like it is incorrectly dealing with the DynamicData method used for retrieving the data. The first entry is retrieved twice (first for the initial call and then second time for actual execution of the data).
Due to this behavior we have a test that is simply failing because its data (a FileStream) is retrieved/opened twice which is (by default) not allowed by the file system.
It is not the most pretty test, but it is a simple and effective test for checking the function that is verifying the version we embed in a file.
This test fails because temp1.x is opened twice and causing the following exception:
Although it is possible to overcome this particular problem by using the FileShare.Read flag, it is undesired (and unexpected) behavior that MSTest is retrieving and locking the resources twice!