Gradle task "test" fails when running cucumber-jvm tests


(Kamil Hakim) #1

Hello, I’m experiencing some problems when I try to run Cucumber-jvm tests. The file RunCukesTest is annotated with @RunWith(Cucumber.class). It can be seen below.

* What went wrong:
Execution failed for task ':test'.
> Could not write XML test results for com.assaabloy.stg.a3p.acceptancetests.RunCukesTest to file C:\Dev\Jobb\arx_trunk\server-rt\AccteptanceTests\build\test-results\TEST-com.assaabloy.stg.a3p.acceptancetests.RunCukesTest.xml.

Also I’ve been able to verify that the tests run and succeed in Intellij. In my quest to solve this on my own I checked out the gradle source code and ran som debugging on my own. I managed to narrow it down to that when writing the xml-report file the last test doesn’t have a name which makes the method write in the class JUnitXmlResultWriter at the row .attribute(“name”, methodResult.getName()) throw a null pointer.

The test suite reports 4 tests for a scenario with three steps in it:

Scenario: Blabha lba

Given: assdf

When: aslkdfj

Then: asdf

The given, when and then steps succeed and have a name, but then a fourth TestMethodResult is added which I belive is the conclusion of the scenario and that one lacks a name.

I’m not sure if this is a bug with Gradle test which can’t handle test methods with null names or if this is a problem with cucumber-jvm, thus I’ll post this here and also on the cucumber-jvm issue tracker.

Best regards, Kamil


(Peter Niederwieser) #2

It’s a known problem. See similar posts in this forum.


(Endre Stølsvik) #3

To turn off the XML-generation, which is the problem: Inside the Test-task: reports.junitXml.enabled = false … and possibly for good measure: reports.html.enabled = false