I have a TestFixture which contains multiple tests. I want to run this TestFixture multiple times to collect some statistics but can't seem to find a reasonable way. The RepeatAttribute cannot be used on a TestFixture.
I can use Nunit or Jenkins (with nunit plugin). Any ideas? Otherwise I would end up coding it into the test or use weird batch scripting.
As Steve says, a parameterized fixture works, but if you want to run your test hundreds of times, it would get fairly tedious to copy and paste that many attributes.
A better option in NUnit is to use the TestFixtureSource attribute on your fixture. For example, the following code will run your test fixture 100 times;
[TestFixtureSource("TestData")]
public class MultipleRunFixture
{
int _counter;
public MultipleRunFixture(int counter)
{
_counter = counter;
}
public static IEnumerable<int> TestData =>
Enumerable.Range(0, 100);
[Test]
public void TestMethod()
{
// TODO: Add your test code here
Assert.Pass($"Test run {_counter}");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With