-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathRequestTest.java
50 lines (40 loc) · 1.54 KB
/
RequestTest.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
package org.junit.runner;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.testsupport.EventCollectorMatchers.hasSingleFailureWithMessage;
import org.junit.Test;
import org.junit.testsupport.EventCollector;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
public class RequestTest {
/**
* #1320 A root of a {@link Description} produced by
* {@link Request#classes(Class...)} should be named "classes"
*/
@Test
public void createsADescriptionWithANameForClasses() {
Description description = Request
.classes(RequestTest.class, RequestTest.class).getRunner()
.getDescription();
assertThat(description.toString(), is("classes"));
}
@Test
public void reportsInitializationErrorThrownWhileCreatingSuite() {
EventCollector collector = new EventCollector();
JUnitCore core = new JUnitCore();
core.addListener(collector);
core.run(new FailingComputer(), FooTest.class, BarTest.class);
assertThat(collector, hasSingleFailureWithMessage("cannot create suite"));
}
private static class FailingComputer extends Computer {
@Override
public Runner getSuite(RunnerBuilder builder, Class<?>[] classes)
throws InitializationError {
throw new InitializationError("cannot create suite");
}
}
private static class FooTest {
}
private static class BarTest {
}
}