@@ -32,6 +32,7 @@ import com.carrotsearch.ant.tasks.junit4.events.aggregated.HeartBeatEvent
32
32
import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener
33
33
import org.gradle.internal.logging.progress.ProgressLogger
34
34
import org.gradle.internal.logging.progress.ProgressLoggerFactory
35
+ import org.junit.runner.Description
35
36
36
37
import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.formatDurationInSeconds
37
38
import static com.carrotsearch.ant.tasks.junit4.events.aggregated.TestStatus.ERROR
@@ -113,7 +114,7 @@ class TestProgressLogger implements AggregatedEventListener {
113
114
114
115
@Subscribe
115
116
void onSuiteStart (AggregatedSuiteStartedEvent e ) throws IOException {
116
- String suiteName = simpleName(e. suiteStartedEvent. description. className )
117
+ String suiteName = simpleName(e. suiteStartedEvent. description)
117
118
slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ suiteName} - initializing" )
118
119
}
119
120
@@ -146,31 +147,45 @@ class TestProgressLogger implements AggregatedEventListener {
146
147
throw new IllegalArgumentException (" Unknown test status: [${ e.status} ]" )
147
148
}
148
149
testLogger. progress(" Tests: completed: ${ testsCompleted} , failed: ${ testsFailed} , ignored: ${ testsIgnored} " )
149
- String testName = simpleName (e. description. className) + ' . ' + e . description . methodName
150
+ String testName = testName (e. description)
150
151
slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ testName} ${ statusMessage} " )
151
152
}
152
153
153
154
@Subscribe
154
155
void onTestStarted (TestStartedEvent e ) throws IOException {
155
- String testName = simpleName (e. description. className) + ' . ' + e . description . methodName
156
+ String testName = testName (e. description)
156
157
slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ testName} ..." )
157
158
}
158
159
159
160
@Subscribe
160
161
void onHeartbeat (HeartBeatEvent e ) throws IOException {
161
- String testName = simpleName (e. description. className) + ' . ' + e . description . methodName
162
+ String testName = testName (e. description)
162
163
String time = formatDurationInSeconds(e. getNoEventDuration())
163
164
slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ testName} stalled for ${ time} " )
164
165
}
165
166
167
+ /**
168
+ * Build the test name in the format of <className>.<methodName>
169
+ */
170
+ private static String testName (Description description ) {
171
+ String className = simpleName(description)
172
+ if (description == null ) {
173
+ return className + " ." + " <unknownMethod>"
174
+ }
175
+ return className + " ." + description. methodName
176
+ }
177
+
166
178
/**
167
179
* Extract a Class#getSimpleName style name from Class#getName style
168
180
* string. We can't just use Class#getSimpleName because junit descriptions
169
181
* don't always set the class field but they always set the className
170
182
* field.
171
183
*/
172
- private static String simpleName (String className ) {
173
- return className. substring(className. lastIndexOf(' .' ) + 1 )
184
+ private static String simpleName (Description description ) {
185
+ if (description == null ) {
186
+ return " <unknownClass>"
187
+ }
188
+ return description. className. substring(description. className. lastIndexOf(' .' ) + 1 )
174
189
}
175
190
176
191
@Override
0 commit comments