File tree Expand file tree Collapse file tree 2 files changed +73
-0
lines changed
students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .litejunit .extension ;
2
+
3
+ import org .litejunit .v2 .Test ;
4
+ import org .litejunit .v2 .TestResult ;
5
+
6
+ /**
7
+ * Created by john on 2017/9/2.
8
+ */
9
+ public class RepeatedTest extends TestDecorator {
10
+ private int fTimesRepeat ;
11
+
12
+ public RepeatedTest (Test test , int repeat ) {
13
+ super (test );
14
+ if (repeat < 0 )
15
+ throw new IllegalArgumentException ("Repetition count must be > 0" );
16
+ fTimesRepeat = repeat ;
17
+ }
18
+
19
+ public int countTestCases () {
20
+ return super .countTestCases () * fTimesRepeat ;
21
+ }
22
+
23
+ public void run (TestResult result ) {
24
+ for (int i = 0 ; i < fTimesRepeat ; i ++) {
25
+ if (result .shouldStop ())
26
+ break ;
27
+ super .run (result );
28
+ }
29
+ }
30
+
31
+ public String toString () {
32
+ return super .toString () + "(repeated)" ;
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ package org .litejunit .extension ;
2
+
3
+ import org .litejunit .v2 .Assert ;
4
+ import org .litejunit .v2 .Test ;
5
+ import org .litejunit .v2 .TestResult ;
6
+
7
+ /**
8
+ * Created by john on 2017/9/2.
9
+ */
10
+ public class TestDecorator extends Assert implements Test {
11
+ protected Test test ;
12
+
13
+ public TestDecorator (Test test ) {
14
+ this .test = test ;
15
+ }
16
+
17
+ /**
18
+ * The basic run behaviour.
19
+ */
20
+ public void basicRun (TestResult result ) {
21
+ test .run (result );
22
+ }
23
+
24
+ public int countTestCases () {
25
+ return test .countTestCases ();
26
+ }
27
+
28
+ public void run (TestResult result ) {
29
+ basicRun (result );
30
+ }
31
+
32
+ public String toString () {
33
+ return test .toString ();
34
+ }
35
+
36
+ public Test getTest () {
37
+ return test ;
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments