blob: 546bed56d6e193e0abc1abc0687a2009e1cfe4fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
namespace NUnit.Extensions {
using System;
using NUnit.Framework;
/// <summary>A Decorator that runs a test repeatedly.</summary>
public class RepeatedTest: TestDecorator {
private readonly int fTimesRepeat;
/// <summary>
///
/// </summary>
/// <param name="test"></param>
/// <param name="repeat"></param>
public RepeatedTest(ITest test, int repeat) : base(test) {
if (repeat < 0) {
throw new ArgumentOutOfRangeException("repeat", "Repetition count must be > 0");
}
fTimesRepeat= repeat;
}
/// <summary>
///
/// </summary>
public override int CountTestCases {
get { return base.CountTestCases * fTimesRepeat; }
}
/// <summary>
///
/// </summary>
/// <param name="result"></param>
public override void Run(TestResult result) {
for (int i= 0; i < fTimesRepeat; i++) {
if (result.ShouldStop)
break;
base.Run(result);
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString() {
return base.ToString()+"(repeated)";
}
}
}
|