prashant-ramcharan / courgette-jvm

Multiprocess | Parallel Cucumber-JVM | Parallelize your Java Cucumber tests on a feature level or on a scenario level.
MIT License
134 stars 39 forks source link

Courgette error processing reports #394

Closed bill2605 closed 9 months ago

bill2605 commented 9 months ago

Hi,

I've been trying to resolve an issue with the following error:

[Courgette Runner] There was an unexpected error processing the individual Cucumber report files and Courgette was unable to create any reports for this test run.

Stack trace:

The following scenarios failed: 
Login Tests - User can login successfully

java.util.NoSuchElementException: No value present
    at java.base/java.util.Optional.get(Optional.java:143)
    at courgette.runtime.CourgetteNdJsonCreator.extractTestCase(CourgetteNdJsonCreator.java:184)
    at courgette.runtime.CourgetteNdJsonCreator.addMessage(CourgetteNdJsonCreator.java:116)
    at courgette.runtime.CourgetteNdJsonCreator.lambda$getScenarioMessages$1(CourgetteNdJsonCreator.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at courgette.runtime.CourgetteNdJsonCreator.lambda$getScenarioMessages$2(CourgetteNdJsonCreator.java:84)
    at java.base/java.util.HashMap.forEach(HashMap.java:1429)
    at courgette.runtime.CourgetteNdJsonCreator.getScenarioMessages(CourgetteNdJsonCreator.java:79)
    at courgette.runtime.CourgetteNdJsonCreator.createScenarioMessages(CourgetteNdJsonCreator.java:63)
    at courgette.runtime.CourgetteReporter.createMessages(CourgetteReporter.java:126)
    at courgette.runtime.CourgetteReporter.<init>(CourgetteReporter.java:33)
    at courgette.runtime.CourgetteRunner.createCucumberReport(CourgetteRunner.java:160)
    at courgette.api.junit.Courgette.run(Courgette.java:62)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:112)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
    at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

Courgette options are:

@RunWith(Courgette.class)
@CourgetteOptions(
        threads = 1,
        runLevel = CourgetteRunLevel.SCENARIO,
        rerunFailedScenarios = true,
        reportTargetDir = "target",
        reportTitle = "Hike Report",
        cucumberOptions = @CucumberOptions(
                features = "src/test/resources/features",
                glue = "com.hike.stepdefinition",
                tags = {"@AndroidReady"},
                publish = true,
                plugin = {
                        "pretty",
                        "json:target/cucumber-report/cucumber.json",
                        "html:target/cucumber-report/cucumber.html",
                        "junit:target/cucumber-report/cucumber.xml"
                }
        ))

Currently using Java 21, with the latest version of the courgette library and cucumber-spring 7.15.0

Any thoughts as to why this is happening? Thanks!

bilal-hike commented 9 months ago

I noticed that when running test via the courgetteRunner class, there is no Before step running in the test, however there would be if I run the tests from the feature file. Also from console, there is no stack trace returned from courgette which makes it hard to debug. See below:

image

It seems like it's able to locate the feature files, but the glue (or test setup hooks with @before and @after are ignored ) ?

bill2605 commented 9 months ago

It seems I was using the wrong JRE version all along.. thanks!