Skip to content

Commit 8a0a412

Browse files
committed
Add TestExecutionListener
1 parent 30de883 commit 8a0a412

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@
108108
<artifactId>spring-boot-starter-webflux</artifactId>
109109
<scope>test</scope>
110110
</dependency>
111+
<dependency>
112+
<groupId>org.junit.platform</groupId>
113+
<artifactId>junit-platform-launcher</artifactId>
114+
<scope>test</scope>
115+
</dependency>
111116

112117
<!-- Additional Spring components -->
113118
<dependency>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* ContainerProxy
3+
*
4+
* Copyright (C) 2016-2021 Open Analytics
5+
*
6+
* ===========================================================================
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the Apache License as published by
10+
* The Apache Software Foundation, either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* Apache License for more details.
17+
*
18+
* You should have received a copy of the Apache License
19+
* along with this program. If not, see <http://www.apache.org/licenses/>
20+
*/
21+
package eu.openanalytics.containerproxy.test.helpers;
22+
23+
import org.junit.platform.engine.TestExecutionResult;
24+
import org.junit.platform.launcher.TestIdentifier;
25+
import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
26+
27+
public class TestExecutionListener extends SummaryGeneratingListener {
28+
29+
public TestExecutionListener() {
30+
31+
}
32+
33+
@Override
34+
public void executionSkipped(TestIdentifier testIdentifier, String reason) {
35+
super.executionSkipped(testIdentifier, reason);
36+
if (testIdentifier == null || reason == null || !testIdentifier.isTest()) return;
37+
38+
System.out.println();
39+
System.out.printf("\t\t--> Skipping test \"%s\"%n", testIdentifier.getDisplayName());
40+
System.out.println();
41+
}
42+
43+
@Override
44+
public void executionStarted(TestIdentifier testIdentifier) {
45+
super.executionStarted(testIdentifier);
46+
if (testIdentifier == null || !testIdentifier.isTest()) return;
47+
48+
System.out.println();
49+
System.out.printf("\t\t--> Started test \"%s\"%n", testIdentifier.getDisplayName());
50+
System.out.println();
51+
}
52+
53+
@Override
54+
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
55+
super.executionFinished(testIdentifier, testExecutionResult);
56+
if (testIdentifier == null || testExecutionResult == null || !testIdentifier.isTest()) return;
57+
58+
System.out.println();
59+
System.out.printf("\t\t--> Finished test \"%s\": %s%n", testIdentifier.getDisplayName(), testExecutionResult);
60+
System.out.println();
61+
}
62+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
eu.openanalytics.containerproxy.test.helpers.TestExecutionListener

0 commit comments

Comments
 (0)