-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
TestBrokenOnlyTestCase.java
104 lines (92 loc) · 4.34 KB
/
TestBrokenOnlyTestCase.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package io.quarkus.vertx.http.testrunner.brokenonly;
import java.util.function.Function;
import java.util.function.Supplier;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import io.quarkus.test.QuarkusDevModeTest;
import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus;
import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils;
import io.restassured.RestAssured;
public class TestBrokenOnlyTestCase {
@RegisterExtension
static QuarkusDevModeTest test = new QuarkusDevModeTest()
.setArchiveProducer(new Supplier<JavaArchive>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class).addClass(BrokenOnlyResource.class)
.add(new StringAsset(ContinuousTestingTestUtils.appProperties()),
"application.properties");
}
})
.setTestArchiveProducer(new Supplier<JavaArchive>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class).addClass(SimpleET.class);
}
});
@Test
public void testBrokenOnlyMode() throws InterruptedException {
TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete();
Assertions.assertEquals(1L, ts.getLastRun());
Assertions.assertEquals(1L, ts.getTestsFailed());
Assertions.assertEquals(1L, ts.getTestsPassed());
Assertions.assertEquals(0L, ts.getTestsSkipped());
Assertions.assertEquals(-1L, ts.getRunning());
//start broken only mode
RestAssured.post("q/dev/io.quarkus.quarkus-vertx-http/tests/toggle-broken-only");
test.modifyTestSourceFile(SimpleET.class, new Function<String, String>() {
@Override
public String apply(String s) {
return s.replace("@QuarkusTest", "@QuarkusTest //noop change");
}
});
ts = ContinuousTestingTestUtils.waitForRun(2);
Assertions.assertEquals(2L, ts.getLastRun());
Assertions.assertEquals(1L, ts.getTestsFailed());
Assertions.assertEquals(0L, ts.getTestsPassed()); //passing test should not have been run
Assertions.assertEquals(0L, ts.getTestsSkipped());
Assertions.assertEquals(-1L, ts.getRunning());
test.modifySourceFile(BrokenOnlyResource.class, new Function<String, String>() {
@Override
public String apply(String s) {
return s.replace("//setup(router);", "setup(router);");
}
});
ts = ContinuousTestingTestUtils.waitForRun(3);
Assertions.assertEquals(3L, ts.getLastRun());
Assertions.assertEquals(0L, ts.getTestsFailed());
Assertions.assertEquals(1L, ts.getTestsPassed());
Assertions.assertEquals(0L, ts.getTestsSkipped());
Assertions.assertEquals(-1L, ts.getRunning());
//now add a new failing test
test.modifyTestSourceFile(SimpleET.class, new Function<String, String>() {
@Override
public String apply(String s) {
return s.replace("//failannotation", "@Test");
}
});
ts = ContinuousTestingTestUtils.waitForRun(4);
Assertions.assertEquals(4L, ts.getLastRun());
Assertions.assertEquals(1L, ts.getTestsFailed());
Assertions.assertEquals(0L, ts.getTestsPassed());
Assertions.assertEquals(0L, ts.getTestsSkipped());
Assertions.assertEquals(-1L, ts.getRunning());
//now make it pass
test.modifyTestSourceFile(SimpleET.class, new Function<String, String>() {
@Override
public String apply(String s) {
return s.replace("Assertions.fail();", "//noop");
}
});
ts = ContinuousTestingTestUtils.waitForRun(5);
Assertions.assertEquals(5L, ts.getLastRun());
Assertions.assertEquals(0L, ts.getTestsFailed());
Assertions.assertEquals(1L, ts.getTestsPassed());
Assertions.assertEquals(0L, ts.getTestsSkipped());
Assertions.assertEquals(-1L, ts.getRunning());
}
}