-
Notifications
You must be signed in to change notification settings - Fork 263
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
Need clean way to share data between parameterized tests #169
Comments
This is being discussed in: microsoft/testfx-docs#12 |
This has been addressed in 1.2.0-beta release of the Framework/Adapter pair. |
Thanks! For others who find this, here's how to try it out: Make sure you have MSTest v1.2.0 or later. At time of writing it's in beta, so need to install yourself using NuGet's "Include prerelease" checkbox: Then, add a static, static object[] Data
{
get => new[]
{
new object[] {1, 2, 3},
new object[] {4, 5, 6}
};
}
[TestMethod]
[DynamicData("Data")]
public void Test1(int a, int b, int c)
{
Assert.AreEqual(1, a % 3);
Assert.AreEqual(2, b % 3);
Assert.AreEqual(0, c % 3);
} You can alternatively use a method that returns an IEnumerable<object[]>, instead of a property. I'm going off this doc. |
MSTest v2 needs a clean way to share test-data between tests. It should support objects.
Current approaches fall short:
Suggest adding the equivalent of NUnit's TestCaseSource, which takes the name of a field, property, or method that returns an IEnumerable (which can handle objects):
The text was updated successfully, but these errors were encountered: