Просмотр исходного кода

Initial POC of how to ignore all-but-first test

Introduce a new JUnit test category that lets us mark certain tests as
not ready for execution. The test task in the individual project
can then be configured to not run tests marked as `NotReady`.

For the CI server builds, add a fullTest test task that simply runs
tests as normal, and link it into the check task so it runs on builds.

This is not perfect, as the class under test must still compile, so it
must have at least the correct signatures of all the methods tested.
Also, it may be worth finding a way to distribute the NotReady interface
that doesn't require checking it into every project.
Emil Sit 10 лет назад
Родитель
Сommit
4825d1acff

+ 7
- 0
exercises/build.gradle Просмотреть файл

19
       println "  (source = " + compileTask.source.asPath + ")"
19
       println "  (source = " + compileTask.source.asPath + ")"
20
     }
20
     }
21
   }
21
   }
22
+
23
+  task fullTest(type: Test) {
24
+    group = LifecycleBasePlugin.VERIFICATION_GROUP
25
+    description = "Runs tests without exclusions."
26
+  }
27
+
28
+  check.dependsOn(fullTest)
22
 }
29
 }

+ 5
- 0
exercises/grade-school/build.gradle Просмотреть файл

11
   testCompile "org.assertj:assertj-core:3.2.0"
11
   testCompile "org.assertj:assertj-core:3.2.0"
12
 }
12
 }
13
 
13
 
14
+test {
15
+    useJUnit {
16
+        excludeCategories 'io.exercism.xjava.NotReady'
17
+    }
18
+}

+ 8
- 0
exercises/grade-school/src/example/java/io/exercism/xjava/NotReady.java Просмотреть файл

1
+package io.exercism.xjava;
2
+
3
+/**
4
+ * Marker interface used to exclude tests as you work
5
+ * through each exercise.
6
+ */
7
+public interface NotReady {
8
+}

+ 8
- 0
exercises/grade-school/src/test/java/SchoolTest.java Просмотреть файл

1
 import static org.assertj.core.api.Assertions.assertThat;
1
 import static org.assertj.core.api.Assertions.assertThat;
2
 
2
 
3
+import io.exercism.xjava.NotReady;
4
+import org.junit.experimental.categories.Category;
3
 import org.junit.Test;
5
 import org.junit.Test;
4
 
6
 
5
 import java.util.Arrays;
7
 import java.util.Arrays;
16
   }
18
   }
17
 
19
 
18
   @Test
20
   @Test
21
+  @Category(NotReady.class)
19
   public void addsStudents() {
22
   public void addsStudents() {
20
     school.add("Aimee", 2);
23
     school.add("Aimee", 2);
21
     assertThat(school.db().get(2)).contains("Aimee");
24
     assertThat(school.db().get(2)).contains("Aimee");
22
   }
25
   }
23
 
26
 
24
   @Test
27
   @Test
28
+  @Category(NotReady.class)
25
   public void addsMoreStudentsInSameGrade() {
29
   public void addsMoreStudentsInSameGrade() {
26
     final int grade = 2;
30
     final int grade = 2;
27
     school.add("James", grade);
31
     school.add("James", grade);
32
   }
36
   }
33
 
37
 
34
   @Test
38
   @Test
39
+  @Category(NotReady.class)
35
   public void addsStudentsInMultipleGrades() {
40
   public void addsStudentsInMultipleGrades() {
36
     school.add("Chelsea", 3);
41
     school.add("Chelsea", 3);
37
     school.add("Logan", 7);
42
     school.add("Logan", 7);
42
   }
47
   }
43
 
48
 
44
   @Test
49
   @Test
50
+  @Category(NotReady.class)
45
   public void getsStudentsInAGrade() {
51
   public void getsStudentsInAGrade() {
46
     school.add("Franklin", 5);
52
     school.add("Franklin", 5);
47
     school.add("Bradley", 5);
53
     school.add("Bradley", 5);
50
   }
56
   }
51
 
57
 
52
   @Test
58
   @Test
59
+  @Category(NotReady.class)
53
   public void getsStudentsInEmptyGrade() {
60
   public void getsStudentsInEmptyGrade() {
54
     assertThat(school.grade(1)).isEmpty();
61
     assertThat(school.grade(1)).isEmpty();
55
   }
62
   }
56
 
63
 
57
   @Test
64
   @Test
65
+  @Category(NotReady.class)
58
   public void sortsSchool() {
66
   public void sortsSchool() {
59
     school.add("Jennifer", 4);
67
     school.add("Jennifer", 4);
60
     school.add("Kareem", 6);
68
     school.add("Kareem", 6);