[TestFixture, TestFixtureSource(nameof(FixtureParms))]
public class TestClass
{
private static bool fixtureAttribute1;
private static int fixtureAttribute2;
public TestClass(bool param1, int param2)
{
fixtureAttribute1 = param1;
fixtureAttribute2 = param2;
}
public static IEnumerable FixtureParms
{
get
{
yield return new TestFixtureData(true, 0);
yield return new TestFixtureData(true, 1);
yield return new TestFixtureData(false, 2);
}
}
public class NameProvider : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield return new TestCaseData
{
TestName = $"{{m}}({fixtureAttribute1}, {fixtureAttribute2})"
};
}
}
[Test, TestCaseSource(typeof(NameProvider))]
public void TestMethod()
{
...
}
}
The goal is to produce three test cases with the names TestMethod(True, 0), TestMethod(True, 1), and TestMethod(False, 2). However when I build/run it, all the 3 names become TestMethod(True,0).
Any feedback would be helpful. Thanks!
On Thursday, June 15, 2017 at 5:40:18 PM UTC-5, Rob Prouse wrote:
Can you provide some example code so we can see what you mean?
Hi All,
I have a TestFixture that takes a TestFixtureData with two arguments, those arguments are stored in static attributes for later. I also have TestCaseSources that provide TestCaseData, and I rename the TestName property using the fixture attributes mentioned before. When I build the project the fixture creates tests based on the two arguments as expected, but the variables used for naming do not get iterated over. The name is always displayed as the first set of fixture arguments.
I was wondering, shouldn't the test names iterate with the TestFixtureData arguments?
If not, does anyone know how to rename tests with fixture data? Using the
Nunit naming template you are able to pull some information, but you're unable to get fixture data if you're calling from a test.
Thanks
--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.