Reputation: 45
I tried to write a Generic Test Method in c# for data-driven unit tests with MS Test. However, this method is not shown in the Test Explorer in VS 2019.
[DataRow(new int[] { 1, 3 }, new int[] { 2 }, new int[] { 1, 2, 3 })]
[DataTestMethod]
public void MergeTwoGenericSortedArrays_Test<T>(T[] a1, T[] a2, T[] r)
where T : IComparable<T>
{
var md = new MergeSortedArrays<T>();
T[] m = md.Merge(a1, a2);
CollectionAssert.AreEqual(r, m);
}
Is it possible to write a test like this or I should find another way?
Upvotes: 3
Views: 817
Reputation: 601
A generic method cannot be a test method. If you switch the Visual Studio Output to "Show output from:" Tests you will find some useful messages.
Upvotes: 2