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