I know this is an old thread, but here is a little trick you can apply if you need to repeat a test a small number of times:
First, create some dummy data:
public static IEnumerable<object[]> DummyTestData()
{
yield return new object[] { 0 };
yield return new object[] { 1 };
yield return new object[] { 2 };
yield return new object[] { 3 };
}
Then use the dummy data in order to force your test to run for each vector. In that case, the same test will be called 4 times (but the dummy data is actually not being used):
private static int _counter = 0;
[Theory]
[MemberData(nameof(DummyTestData))]
public void SomeTest(int dummyParam) // dummyParam is unused
{
_counter+= 1;
DoSomething();
Assert.True(...);
}
I find this approach very useful and less cumbesome than creating a new attribute.
Of course, this is not a good solution if you need the number of repetitions to be parameterisable (although I am sure someone could suggest a way to make my solution parameterisable :-)).
Type[] parameterTypes
parameter fromGetData
, though. Now if this would just work with other attributes likeCombinatorialData
. – Seymourseys