/
ReportingTest.java
61 lines (46 loc) · 1.88 KB
/
ReportingTest.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
/*
* Copyright 2015-2016 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.junit.gen5.engine.junit5;
import static org.junit.gen5.api.Assertions.assertEquals;
import static org.junit.gen5.engine.discovery.ClassSelector.forClass;
import static org.junit.gen5.launcher.main.TestDiscoveryRequestBuilder.request;
import java.util.HashMap;
import org.junit.gen5.api.AfterEach;
import org.junit.gen5.api.BeforeEach;
import org.junit.gen5.api.Test;
import org.junit.gen5.api.TestReporter;
import org.junit.gen5.commons.reporting.ReportingEntry;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.launcher.TestDiscoveryRequest;
public class ReportingTest extends AbstractJUnit5TestEngineTests {
@Test
public void threeReportEntriesArePublished() {
TestDiscoveryRequest request = request().select(forClass(MyReportingTestCase.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0L, eventRecorder.getTestFailedCount(), "# tests failed");
assertEquals(3L, eventRecorder.getReportingEntryPublishedCount(), "# report entries published");
}
static class MyReportingTestCase {
@BeforeEach
void before(TestReporter reporter) {
reporter.publishEntry(new ReportingEntry(new HashMap<>()));
}
@AfterEach
void after(TestReporter reporter) {
reporter.publishEntry(new ReportingEntry(new HashMap<>()));
}
@Test
void succeedingTest(TestReporter reporter) {
reporter.publishEntry(new ReportingEntry(new HashMap<>()));
}
}
}