Skip to content

Commit a70cb6f

Browse files
committed
Log which test is being run
1 parent d54b2ba commit a70cb6f

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@
100100
<version>${kotlin.version}</version>
101101
<scope>test</scope>
102102
</dependency>
103+
<dependency>
104+
<groupId>org.junit.platform</groupId>
105+
<artifactId>junit-platform-launcher</artifactId>
106+
<version>1.7.0</version>
107+
<scope>test</scope>
108+
</dependency>
103109
<dependency>
104110
<groupId>org.junit.jupiter</groupId>
105111
<artifactId>junit-jupiter</artifactId>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
eu.openanalytics.shinyproxyoperator.helpers.junit.TestExecutionListener
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* ShinyProxy-Operator
3+
*
4+
* Copyright (C) 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.shinyproxyoperator.helpers.junit
22+
23+
import org.junit.platform.engine.TestExecutionResult
24+
import org.junit.platform.launcher.TestIdentifier
25+
import org.junit.platform.launcher.listeners.SummaryGeneratingListener
26+
import java.io.PrintWriter
27+
28+
class TestExecutionListener : SummaryGeneratingListener() {
29+
30+
init {
31+
Runtime.getRuntime().addShutdownHook(Thread {
32+
summary.printTo(PrintWriter(System.out))
33+
})
34+
}
35+
36+
override fun executionSkipped(testIdentifier: TestIdentifier?, reason: String?) {
37+
super.executionSkipped(testIdentifier, reason)
38+
if (testIdentifier == null || reason == null || !testIdentifier.isTest) return
39+
40+
println()
41+
println("\t\t--> Skipping test \"${testIdentifier.displayName}\"")
42+
println()
43+
}
44+
45+
override fun executionStarted(testIdentifier: TestIdentifier?) {
46+
super.executionStarted(testIdentifier)
47+
if (testIdentifier == null || !testIdentifier.isTest) return
48+
49+
println()
50+
println("\t\t--> Started test \"${testIdentifier.displayName}\"")
51+
println()
52+
}
53+
54+
override fun executionFinished(testIdentifier: TestIdentifier?, testExecutionResult: TestExecutionResult?) {
55+
super.executionFinished(testIdentifier, testExecutionResult)
56+
if (testIdentifier == null || testExecutionResult == null || !testIdentifier.isTest) return
57+
58+
println()
59+
println("\t\t--> Finished test \"${testIdentifier.displayName}\": $testExecutionResult")
60+
println()
61+
}
62+
63+
}

0 commit comments

Comments
 (0)