Given the following code:
C#public class Tests
{
[Test, TestCaseSource("GetTestDefinitions")]
public void Test(TestDefinition definition)
{
Assert.AreEqual(definition.Value1, definition.Value2);
}
public static IEnumerable GetTestDefinitions()
{
return new[]
{
new TestDefinition { Value1 = "0", Value2 = "0" },
new TestDefinition { Value1 = "0", Value2 = "1" },
new TestDefinition { Value1 = "1", Value2 = "0" },
new TestDefinition { Value1 = "1", Value2 = "1" },
};
}
public class TestDefinition
{
public string Value1 { get; set; }
public string Value2 { get; set; }
}
}
The 4 tests are not properly represented in the Test Runner:
* Only one test appears
* Its name matches the test case method signature
* If there are failing tests it still shows green (this one is the biggest problem for me)
The output pane shows that all tests were executed: Summary: Passed: 2, Failed: 2, Ignored: 0
Note: ticket T418389 seems to be reporting the same problem but with a focus on the TestCaseData name attribute
Hi,
Thank you for providing the code snippet.
I have reproduced the problem on my side. As a temporary workaround, you can add the ToString method to your "TestDefinition" class, so the classes will be as in the following code snippet:
public class Tests { [Test, TestCaseSource("GetTestDefinitions")] public void Test(TestDefinition definition) { Assert.AreEqual(definition.Value1, definition.Value2); } public static IEnumerable GetTestDefinitions() { return new[] { new TestDefinition { Value1 = "0", Value2 = "0" }, new TestDefinition { Value1 = "0", Value2 = "1" }, new TestDefinition { Value1 = "1", Value2 = "0" }, new TestDefinition { Value1 = "1", Value2 = "1" }, }; } public class TestDefinition { public string Value1 { get; set; } public string Value2 { get; set; } public override string ToString() { return $"Value1: {Value1} Value2: {Value2}"; } } }
We will try to fix the issue as soon as possible. Once we resolve the problem, we will let you know.
I think I had tried that but for some reason I wasn't able to make it work.
Anyway, I was now able to do it. Thanks a lot for the response and the workaround.
You are welcome. We are doing our best to fix this problem and will notify you of our progress shortly.
Hi Jorge,
We found that the fix for this issue has some side effects. We need some time to make and test additional changes. So, we have decided to exclude this fix from the nearest 16.1.9 release. We will make every effort to finally solve this problem in the 16.1.10 release. Your patience is greatly appreciated.