@@ -32,6 +32,7 @@ import com.carrotsearch.ant.tasks.junit4.events.aggregated.HeartBeatEvent
3232import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener
3333import org.gradle.internal.logging.progress.ProgressLogger
3434import org.gradle.internal.logging.progress.ProgressLoggerFactory
35+ import org.junit.runner.Description
3536
3637import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.formatDurationInSeconds
3738import static com.carrotsearch.ant.tasks.junit4.events.aggregated.TestStatus.ERROR
@@ -113,7 +114,7 @@ class TestProgressLogger implements AggregatedEventListener {
113114
114115 @Subscribe
115116 void onSuiteStart (AggregatedSuiteStartedEvent e ) throws IOException {
116- String suiteName = simpleName(e. suiteStartedEvent. description. className )
117+ String suiteName = simpleName(e. suiteStartedEvent. description)
117118 slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ suiteName} - initializing" )
118119 }
119120
@@ -146,31 +147,45 @@ class TestProgressLogger implements AggregatedEventListener {
146147 throw new IllegalArgumentException (" Unknown test status: [${ e.status} ]" )
147148 }
148149 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)
150151 slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ testName} ${ statusMessage} " )
151152 }
152153
153154 @Subscribe
154155 void onTestStarted (TestStartedEvent e ) throws IOException {
155- String testName = simpleName (e. description. className) + ' . ' + e . description . methodName
156+ String testName = testName (e. description)
156157 slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ testName} ..." )
157158 }
158159
159160 @Subscribe
160161 void onHeartbeat (HeartBeatEvent e ) throws IOException {
161- String testName = simpleName (e. description. className) + ' . ' + e . description . methodName
162+ String testName = testName (e. description)
162163 String time = formatDurationInSeconds(e. getNoEventDuration())
163164 slaveLoggers[e. slave. id]. progress(" J${ e.slave.id} : ${ testName} stalled for ${ time} " )
164165 }
165166
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+
166178 /**
167179 * Extract a Class#getSimpleName style name from Class#getName style
168180 * string. We can't just use Class#getSimpleName because junit descriptions
169181 * don't always set the class field but they always set the className
170182 * field.
171183 */
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 )
174189 }
175190
176191 @Override
0 commit comments