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

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,4 +19,11 @@ subprojects { project ->
19 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,3 +11,8 @@ dependencies {
11 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 Просмотреть файл

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