serenity-bdd / serenity-cucumber-starter

A skeleton project for Serenity BDD and Cucumber JVM
Apache License 2.0
180 stars 285 forks source link

Suitable Docker Container? #67

Closed cjekal closed 2 years ago

cjekal commented 2 years ago

Hello, I'm trying to run this repo as is (no changes) using gradle test, but I'm getting an error. I'm using the gradle:jdk11 docker image. Here's the output I'm getting:

Welcome to Gradle 7.3.3!

Here are the highlights of this release:
 - Easily declare new test suites in Java projects
 - Support for Java 17
 - Support for Scala 3

For more details see https://docs.gradle.org/7.3.3/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :test

starter.CucumberTestSuite STANDARD_OUT
    05:02:13.406 [Test worker] INFO  i.c.core.plugin.SerenityReporter - Running feature from file:///home/gradle/project/src/test/resources/features/search/search_by_keyword.feature
    05:02:14.053 [Test worker] INFO   - 

    -------------------------------------------------------------------------------------
         _______. _______ .______       _______ .__   __.  __  .___________.____    ____ 
        /       ||   ____||   _  \     |   ____||  \ |  | |  | |           |\   \  /   / 
       |   (----`|  |__   |  |_)  |    |  |__   |   \|  | |  | `---|  |----` \   \/   /  
        \   \    |   __|  |      /     |   __|  |  . `  | |  |     |  |       \_    _/   
    .----)   |   |  |____ |  |\  \----.|  |____ |  |\   | |  |     |  |         |  |     
    |_______/    |_______|| _| `._____||_______||__| \__| |__|     |__|         |__|    

     News and tutorials at http://www.serenity-bdd.info                                  
     Documentation at https://wakaleo.gitbooks.io/the-serenity-book/content/             
     Join the Serenity Community on Gitter: https://gitter.im/serenity-bdd/serenity-core 
     Serenity BDD Support and Training at http://serenity-bdd.info/#/trainingandsupport  
    -------------------------------------------------------------------------------------

    05:02:14.080 [Test worker] INFO   - Test Suite Started: Search by keyword
    05:02:14.158 [Test worker] INFO  i.c.core.plugin.SerenityReporter - Running feature from file:///home/gradle/project/src/test/resources/features/search/search_by_keyword.feature
    05:02:14.167 [Test worker] INFO   - Test Suite Started: Search by keyword

starter.CucumberTestSuite > Search by keyword.Searching for a term STANDARD_OUT

    Scenario: Searching for a term                       # src/test/resources/features/search/search_by_keyword.feature:3
    05:02:14.649 [Test worker] INFO  i.c.core.plugin.SerenityReporter - Running feature from file:///home/gradle/project/src/test/resources/features/search/search_by_keyword.feature
    05:02:15.031 [Test worker] INFO   - 
      _____   ___   ___   _____     ___   _____     _     ___   _____   ___   ___  
     |_   _| | __| / __| |_   _|   / __| |_   _|   /_\   | _ \ |_   _| | __| |   \ 
       | |   | _|  \__ \   | |     \__ \   | |    / _ \  |   /   | |   | _|  | |) |
       |_|   |___| |___/   |_|     |___/   |_|   /_/ \_\ |_|_\   |_|   |___| |___/ 

    Searching for a term(search-by-keyword;searching-for-a-term)
    --------------------------------------------------------------------------------

starter.CucumberTestSuite > Search by keyword.Searching for a term FAILED
    java.lang.ExceptionInInitializerError at TestAnnotations.java:49
        Caused by: java.lang.IllegalStateException at TestFramework.java:33

starter.CucumberTestSuite STANDARD_OUT
          java.lang.ExceptionInInitializerError
        at net.thucydides.core.annotations.TestAnnotations.isIgnored(TestAnnotations.java:49)
        at net.thucydides.core.steps.BaseStepListener.setDefaultResultFromAnnotations(BaseStepListener.java:749)
        at net.thucydides.core.steps.BaseStepListener.recordStep(BaseStepListener.java:734)
        at net.thucydides.core.steps.BaseStepListener.stepStarted(BaseStepListener.java:687)
        at net.thucydides.core.steps.StepEventBus.stepStarted(StepEventBus.java:422)
        at net.thucydides.core.steps.StepEventBus.stepStarted(StepEventBus.java:411)
        at io.cucumber.core.plugin.SerenityReporter.handleTestStepStarted(SerenityReporter.java:346)
        at io.cucumber.core.eventbus.AbstractEventPublisher.send(AbstractEventPublisher.java:51)
        at io.cucumber.core.eventbus.AbstractEventBus.send(AbstractEventBus.java:12)
        at io.cucumber.core.runtime.SynchronizedEventBus.send(SynchronizedEventBus.java:47)
        at io.cucumber.core.runtime.ThreadLocalRunnerSupplier$LocalEventBus.send(ThreadLocalRunnerSupplier.java:62)
        at io.cucumber.core.runner.TestStep.emitTestStepStarted(TestStep.java:74)
        at io.cucumber.core.runner.TestStep.run(TestStep.java:52)
        at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
        at io.cucumber.core.runner.TestCase.run(TestCase.java:95)
        at io.cucumber.core.runner.Runner.runPickle(Runner.java:75)
        at io.cucumber.junit.PickleRunners$NoStepDescriptions.lambda$run$0(PickleRunners.java:151)
        at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$3(CucumberExecutionContext.java:110)
        at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
        at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:110)
        at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:148)
        at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:144)
        at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:28)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at io.cucumber.junit.FeatureRunner.run(FeatureRunner.java:137)
        at io.cucumber.junit.CucumberSerenityRunner.runChild(CucumberSerenityRunner.java:259)
        at io.cucumber.junit.CucumberSerenityRunner.runChild(CucumberSerenityRunner.java:58)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at io.cucumber.junit.CucumberSerenityRunner$RunCucumber.evaluate(CucumberSerenityRunner.java:287)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
        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:38)
        at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        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 com.sun.proxy.$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:133)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
    Caused by: java.lang.IllegalStateException: No Test Strategy Adapter found: To run JUnit tests in Serenity make sure that either the Serenity JUnit 4 (serenity-junit) or JUnit 5 (serenity-junit5) dependency is available.
        at net.thucydides.core.adapters.TestFramework.<clinit>(TestFramework.java:33)
        ... 64 more

    05:02:17.963 [Test worker] INFO  i.c.core.plugin.SerenityReporter - Cleanup test resources for URI file:///home/gradle/project/src/test/resources/features/search/search_by_keyword.feature

starter.CucumberTestSuite > classMethod FAILED
    java.lang.NoClassDefFoundError at SerenityTestCaseFinder.java:11

2 tests completed, 2 failed

> Task :test FAILED

> Task :aggregate
Generating Serenity Reports
  - Main report: file:///home/gradle/project/target/site/serenity/index.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/gradle/project/build/reports/tests/test/index.html

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 45s
5 actionable tasks: 5 executed

Any hints or preferred docker images to use?

cjekal commented 2 years ago

What's weird is that the error seems to be around not finding a Test Strategy Adapter. I've tried matching my Docker container's gradle version to my host's gradle version (7.2) and that did not seem to resolve things. It seems weird that serenity-bdd gets past the No Test Strategy Adapter found: To run JUnit tests in Serenity make sure that either the Serenity JUnit 4 (serenity-junit) or JUnit 5 (serenity-junit5) dependency is available. just fine locally, but not within a container. Any tips/tricks for troubleshooting classpath issues?

wakaleo commented 2 years ago

Hmmm, I've never come across this. The Serenity smoke tests and demo tests are run routinely on Github with Github Actions (e.g. https://github.com/bdd-in-action/flying-high-acceptance-tests/blob/main/.github/workflows/maven.yml and https://github.com/serenity-bdd/serenity-core/blob/master/.github/workflows/smoketest_chrome.yml) - maybe they could give you some clues.

cjekal commented 2 years ago

Thanks @wakaleo I've tried a Docker container with gradle 7.3, gradle 7.2, and maven 3.6.3. I've also tried selenium/selenium-chrome and selenium/node-chrome. Do you have any sample github actions that run the gradle side of things? (i'm personally a bigger fan of gradle ^_^)

cjekal commented 2 years ago

We think we figured it out. We were trying to run this in Docker with a random user, and so when gradle downloaded dependencies, it was ending up in a '?' folder. Switching to a real user fixes the issue. Thanks @wakaleo for your help and input!