Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataTestMethod] is not allowed to be a Generic method #2402

Open
mlsomers opened this issue Feb 20, 2024 · 3 comments · May be fixed by #4204
Open

[DataTestMethod] is not allowed to be a Generic method #2402

mlsomers opened this issue Feb 20, 2024 · 3 comments · May be fixed by #4204

Comments

@mlsomers
Copy link

Describe the bug

A test marked with the [DataTestMethod] attribute cannot have a generic parameter. It will not be recognized by the test runner.

Steps To Reproduce

[TestClass]
public class GTest
{
  [DataTestMethod]
  [DataRow((byte)10)]
  [DataRow((short)11)]
  [DataRow((long)12)]
  [DataRow((ulong)13)]
  public void GenericTest<T>(T value)
  {
    List<T> list = new List<T>(new[] {value});
    Assert.AreEqual<T>(value, list[0]);
  }
}

Expected behavior

The test framework should invoke the method of type T with the correct type of the given argument in DataRow.

Actual behavior

The test framework ignores the whole test.

Additional context

Ran into this limitation while migrating my LsMsgPack project from NUnit to MsTest. The last 100 or so tests in MpIntTest.cs are ignored. The old tests in Nunit are working.

@Evangelink
Copy link
Member

Hi @mlsomers,

Generics are indeed not supported at the moment. Marking this as a feature request.

In the meantime, you will have to work with object.

@Evangelink
Copy link
Member

@Youssef1313 could you please do a quick investigation on complexity there?

@Youssef1313
Copy link
Member

Assigning myself so that I don't forget. I'll validate how much work is needed here.

@Youssef1313 Youssef1313 self-assigned this Dec 1, 2024
@Youssef1313 Youssef1313 linked a pull request Dec 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants