-
Notifications
You must be signed in to change notification settings - Fork 384
Expand file tree
/
Copy pathJUnit5MatcherAssumeTest.java
More file actions
44 lines (38 loc) · 1.21 KB
/
JUnit5MatcherAssumeTest.java
File metadata and controls
44 lines (38 loc) · 1.21 KB
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
package org.hamcrest;
import org.junit.jupiter.api.Test;
import org.opentest4j.TestAbortedException;
import static org.hamcrest.MatcherAssume.assumeThat;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests compatibility with JUnit 5 with only JUnit 5 on the classpath.
* The equivalent test with JUnit 4 <i>and</i> JUnit 5 on the classpath is in another module.
*/
class JUnit5MatcherAssumeTest {
@Test
void
assumptionFailsWithMessage() {
try {
assumeThat("Custom assumption", "a", startsWith("abc"));
fail("should have failed");
}
catch (TestAbortedException e) {
assertEquals("Assumption failed: Custom assumption", e.getMessage());
}
}
@Test void
assumptionFailsWithDefaultMessage() {
try {
assumeThat("a", startsWith("abc"));
fail("should have failed");
}
catch (TestAbortedException e) {
assertEquals("Assumption failed", e.getMessage());
}
}
@Test void
assumptionSucceeds() {
assumeThat("xyz", startsWith("xy"));
}
}