Failed to notify test output listener in Gradle 1.4


(Mark Petrovic) #1

I have some CucumberJVM tests that run fine in Gradle 1.3. When I run them with Gradle 1.4, I see this type of output:

16:13:40.171 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: received class org.gradle.logging.internal.LogEvent
16:13:40.154 [ERROR] [org.gradle.messaging.actor.internal.DefaultActorFactory$NonBlockingActor] Failed to notify test output listener.
org.gradle.listener.ListenerNotificationException: Failed to notify test output listener.
 at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:90)
 at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
 at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
 at $Proxy33.onOutput(Unknown Source)
 at org.gradle.api.internal.tasks.testing.results.TestListenerAdapter.output(TestListenerAdapter.java:54)
 at org.gradle.api.internal.tasks.testing.results.StateTrackingTestResultProcessor.output(StateTrackingTestResultProcessor.java:79)
 at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.output(AttachParentTestResultProcessor.java:45)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
 at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
 at org.gradle.messaging.dispatch.FailureHandlingDispatch.dispatch(FailureHandlingDispatch.java:29)
 at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
 at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
 at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
 at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
 at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
 at com.google.common.base.Joiner.toString(Joiner.java:532)
 at com.google.common.base.Joiner.appendTo(Joiner.java:124)
 at com.google.common.base.Joiner.appendTo(Joiner.java:181)
 at com.google.common.base.Joiner.join(Joiner.java:237)
 at com.google.common.base.Joiner.join(Joiner.java:226)
 at org.gradle.api.internal.tasks.testing.logging.AbstractTestLogger.getEventPath(AbstractTestLogger.java:83)
 at org.gradle.api.internal.tasks.testing.logging.AbstractTestLogger.logEvent(AbstractTestLogger.java:54)
 at org.gradle.api.internal.tasks.testing.logging.TestEventLogger.onOutput(TestEventLogger.java:61)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
 at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
 at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:81)
 ... 20 more

Other supporting information:

JUnit version: 4.10 CucumberJVM version: 1.0.1

Does anyone recognize what might be the problem?

Thanks.


(Luke Daley) #2

Hi Mark,

Would you be able to provide a reproducible sample?


(Mark Petrovic) #3

Thanks.

Ok, I ripped out enough of the cucumber code into a sample project to reproduce the problem.

https://github.com/ae6rt/cucumberjvm-gradle14.git

Be aware that the code does not quite work from an application perspective. By that I mean that when I do this:

~/tools/gradle-1.3/bin/gradle -Dtags="@hello" clean intTest

both cuke tags in helloworld.feature run, where only the @hello tag should. The codebase from which I rather hastily ripped this actually does select the right tag to run, but somewhere in the ripping I broke it. It’s probably a oneline fix somewhere in some app config, but it does not preclude the NPE that is the original subject of this thread from appearing when run under Gradle 1.4.

Hope that helps. If you need more, ask.

Mark


(Szczepan Faber) #4

Can you test with the nightly? I recall that there’re some improvements in the area in the current master (1.5)


(Mark Petrovic) #5

Thanks, Szczepan.

I just tested with the latest nightly build and the NPE is not produced.

Was there something related to how Cucumber runs that changed?


(Mark Petrovic) #6

Incidentally, I’ve seen this Cucumber + Gradle workaround a few times in the last several months, as I’ve migrated from Maven to Gradle:

https://github.com/dkowis/cucumber-jvm-groovy-example/blob/master/build.gradle

For whatever happy reason, I have not had to resort to this technique. To simplify, I just have @RunWith(Cucumber.class) annotating a test class in the canonical Cucumber+Java way, and JUnit seems to do fine handling the actual scenario execution.

So why does my set of Cucumber scenarios continue to run fine, while dkowis above had to resort to a custom task?

Thanks.


(Szczepan Faber) #7

Hey Mark,

I vaguely remember someone talking about some changes either related to cucumber or testing. We’ve done also various refactorings in the test execution. I’m afraid I cannot link you to a commit that fixed the problem :slight_smile:


(enrico.comiti) #8

Hi,

I’m trying with the latest nightly (1.6-20130304214521+0000, Windows) on a personal project and the sample project https://github.com/ae6rt/cucumberjvm-gradle14.git provided from Mark.

I confirm the original problem is solved, but I have another (in both the projects):

Could not write XML test results for Scenario: Say goodbye

to file …\test-results\TEST-Scenario: Say goodbye

.xml.

The --stacktrace gives for the sample project:

Caused by: org.gradle.api.GradleException: Could not write XML test results for Scenario: Say goodbye

to file …\test-results\TEST-Scenario: Say goodbye

.xml.

at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator$1.execute(Binary2JUnitXmlReportGenerator.java:57)

[…]

Caused by: java.lang.NullPointerException

at org.gradle.api.internal.xml.SimpleMarkupWriter.writeXmlAttributeEncoded(SimpleMarkupWriter.java:372)

In my project result is something similar to:

Caused by: org.gradle.api.GradleException: Could not write XML test results for When I run “ruby ./path/to/command --version”

to file …\test-results\TEST-When I run “ruby ./path/to/command --version”

.xml.

at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator$1.execute(Binary2JUnitXmlReportGenerator.java:57)

In my case, it seems to me something related to special chars such as " , @, /, \

Enrico


(Ryan Nelson) #9

I’m getting a similar problem running JBehave stories when migrating from 1.3 to 1.6. The tests appear to all pass … the problem is generating the test report. The version of JBehave is 3.6.9.

Caused by: org.gradle.api.GradleException: Could not write XML test results for Scenario: Import new and existing students specifying max grade limit to file C:\dev\java\workspace\sm\testIntegration\build\test-results\TEST-Scenario: Import new and existing students specifying max grade limit.xml.

at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator$1.execute(Binary2JUnitXmlReportGenerator.java:57)

at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator$1.execute(Binary2JUnitXmlReportGenerator.java:48)

Caused by: java.lang.NullPointerException

at org.gradle.api.internal.xml.SimpleMarkupWriter.writeXmlAttributeEncoded(SimpleMarkupWriter.java:372)

at org.gradle.api.internal.xml.SimpleMarkupWriter.attribute(SimpleMarkupWriter.java:241)


(Mark Petrovic) #10

Gradle 1.7 will have an option to suppress the creation of these test reports. I’m waiting for it, too.


(Ryan Nelson) #11

That would work, but it would still be nice to have the reports. :slight_smile:

As I do more research on this, I think it has something to do with the runner I’m using. When I use the default JBehave runner (AnnotatedEmbedderRunner) it works fine. When I use a 3rd party runner (JUnitReportingRunner) it fails.

I suspect it’s similar to the problem this commit was meant to fix in Cucumber … something is wrong with the way Gradle 1.4 expects the runners to generate descriptions for the test method names. I haven’t figured it all out yet, but I’ll keep looking at it.


(Endre Stølsvik) #12

Inside the Test-task: reports.junitXml.enabled = false … and possibly for good measure: reports.html.enabled = false


(melody_dunn) #13

This problem still exists in Gradle 1.8. Here is a reproducible example: https://github.com/esdrasbeleza/JBehaveWithGradle

How can I get a junit report with gradle and JBehave?


(Peter Niederwieser) #14

Most likely, Gradle will have to be specially adapted to cope with JBehave as well. Are you interested in contributing a solution?


(Paul Grove) #15

I am having a similar issue running Cucumber tests


(Peter Niederwieser) #16

Which Gradle version? Can you try with 1.8?