Skip to content

Commit 4825d1a

Browse files
committed
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.
1 parent a8813f2 commit 4825d1a

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎exercises/build.gradle‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@ subprojects { project ->
1919
println " (source = " + compileTask.source.asPath + ")"
2020
}
2121
}
22+
23+
task fullTest(type: Test) {
24+
group = LifecycleBasePlugin.VERIFICATION_GROUP
25+
description = "Runs tests without exclusions."
26+
}
27+
28+
check.dependsOn(fullTest)
2229
}

‎exercises/grade-school/build.gradle‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ dependencies {
1111
testCompile "org.assertj:assertj-core:3.2.0"
1212
}
1313

14+
test {
15+
useJUnit {
16+
excludeCategories 'io.exercism.xjava.NotReady'
17+
}
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

‎exercises/grade-school/src/test/java/SchoolTest.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import static org.assertj.core.api.Assertions.assertThat;
22

3+
import io.exercism.xjava.NotReady;
4+
import org.junit.experimental.categories.Category;
35
import org.junit.Test;
46

57
import java.util.Arrays;
@@ -16,12 +18,14 @@ public void startsWithNoStudents() {
1618
}
1719

1820
@Test
21+
@Category(NotReady.class)
1922
public void addsStudents() {
2023
school.add("Aimee", 2);
2124
assertThat(school.db().get(2)).contains("Aimee");
2225
}
2326

2427
@Test
28+
@Category(NotReady.class)
2529
public void addsMoreStudentsInSameGrade() {
2630
final int grade = 2;
2731
school.add("James", grade);
@@ -32,6 +36,7 @@ public void addsMoreStudentsInSameGrade() {
3236
}
3337

3438
@Test
39+
@Category(NotReady.class)
3540
public void addsStudentsInMultipleGrades() {
3641
school.add("Chelsea", 3);
3742
school.add("Logan", 7);
@@ -42,6 +47,7 @@ public void addsStudentsInMultipleGrades() {
4247
}
4348

4449
@Test
50+
@Category(NotReady.class)
4551
public void getsStudentsInAGrade() {
4652
school.add("Franklin", 5);
4753
school.add("Bradley", 5);
@@ -50,11 +56,13 @@ public void getsStudentsInAGrade() {
5056
}
5157

5258
@Test
59+
@Category(NotReady.class)
5360
public void getsStudentsInEmptyGrade() {
5461
assertThat(school.grade(1)).isEmpty();
5562
}
5663

5764
@Test
65+
@Category(NotReady.class)
5866
public void sortsSchool() {
5967
school.add("Jennifer", 4);
6068
school.add("Kareem", 6);

0 commit comments

Comments
 (0)