serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
720 stars 519 forks source link

Caused by: java.lang.ClassNotFoundException: net.thucydides.core.model.TestStep after updating Serenity version >= 4 #3318

Open kamal-kaur04 opened 11 months ago

kamal-kaur04 commented 11 months ago

What happened?

Getting below exception when trying to bump Serenity version v4+ :

net.serenitybdd.core.exceptions.StepInitialisationException: Failed to create step library for SerenityReporter:Could not create type
        at net.thucydides.core.steps.StepFactory.getNewCachedStepLibraryFor(StepFactory.java:145)
        at net.thucydides.core.steps.StepFactory.getSharedStepLibraryFor(StepFactory.java:120)
        at net.thucydides.core.steps.IndividualInstancesByDefaultStepCreationStrategy.initiateStepsFor(IndividualInstancesByDefaultStepCreationStrategy.java:15)
        at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:89)
        at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:70)
        at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:52)
        at net.serenitybdd.core.Serenity.injectScenarioStepsInto(Serenity.java:147)
        at net.serenitybdd.core.Serenity.initializeWithNoStepListener(Serenity.java:115)
        at cucumber.runtime.SerenityObjectFactory.newInstance(SerenityObjectFactory.java:74)
        at cucumber.runtime.SerenityObjectFactory.cacheNewInstance(SerenityObjectFactory.java:57)
        at cucumber.runtime.SerenityObjectFactory.getInstance(SerenityObjectFactory.java:47)
        at io.cucumber.java8.Java8Backend.buildWorld(Java8Backend.java:65)
        at io.cucumber.core.runner.Runner.buildBackendWorlds(Runner.java:136)
        at io.cucumber.core.runner.Runner.runPickle(Runner.java:70)
        at io.cucumber.junit.platform.engine.CucumberEngineExecutionContext.lambda$runTestCase$4(CucumberEngineExecutionContext.java:112)
        at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:137)
        at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
        at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:137)
        at io.cucumber.junit.platform.engine.CucumberEngineExecutionContext.runTestCase(CucumberEngineExecutionContext.java:109)
        at io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor.execute(NodeDescriptor.java:168)
        at io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor.execute(NodeDescriptor.java:90)
        at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.IllegalArgumentException: Could not create type
        at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:170)
        at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
        at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
        at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
        at net.thucydides.core.steps.StepFactory.load(StepFactory.java:269)
        at net.thucydides.core.steps.StepFactory.createProxyStepLibrary(StepFactory.java:238)
        at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:188)
        at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:179)
        at net.thucydides.core.steps.StepFactory.getNewCachedStepLibraryFor(StepFactory.java:139)
        ... 26 more
Caused by: java.lang.NoClassDefFoundError: net/thucydides/core/model/TestStep
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
        at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504)
        at net.bytebuddy.description.method.MethodList$ForLoadedMethods.<init>(MethodList.java:152)
        at net.bytebuddy.description.type.TypeDescription$ForLoadedType.getDeclaredMethods(TypeDescription.java:8940)
        at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType.getDeclaredMethods(TypeDescription.java:3711)
        at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.getDeclaredMethods(TypeDescription.java:6210)
        at net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy$Default$5.doExtractConstructors(ConstructorStrategy.java:175)
        at net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy$Default.extractConstructors(ConstructorStrategy.java:196)
        at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.applyConstructorStrategy(SubclassDynamicTypeBuilder.java:242)
        at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.toTypeWriter(SubclassDynamicTypeBuilder.java:212)
        at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.toTypeWriter(SubclassDynamicTypeBuilder.java:203)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4055)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3739)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:3991)
        at net.thucydides.core.steps.StepFactory.lambda$load$2(StepFactory.java:272)
        at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
        ... 34 more
Caused by: java.lang.ClassNotFoundException: net.thucydides.core.model.TestStep
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 51 more

What did you expect to happen?

Tests should run on BrowserStack with proper session name and status.

Serenity BDD version

LTS (4.0.19)

JDK version

17

Execution environment

How to reproduce the bug.

https://github.com/kamal-kaur04/serenity-tests

How can we make it happen?

Hire the Serenity BDD team

kamal-kaur04 commented 11 months ago

@wakaleo There is one more issue, when running with serenity v3.9.8 the session status is not getting marked using serenity-browserstack-plugin, is this something known with jUnit5 runner?

wakaleo commented 11 months ago

Here is what I could find:

I would probably recommend removing webdriver-overload and the custom driver, and rewriting the tests using more idiomatic Serenity features (see https://github.com/serenity-bdd/serenity-core/tree/main/serenity-smoketests or https://github.com/serenity-dojo/swaglabs-serenity-cucumber.git for example).

kamal-kaur04 commented 10 months ago

@wakaleo Thanks pointing this out, it worked after bumping webdriver-overload version to latest. Now, have noticed an issue that the session status on BrowserStack is not getting marked. setSessionName is working fine.

Could you please let us know if what causes this?

wakaleo commented 10 months ago

To get the browserstack status updates when running with Cucumber 7 you need to run with a recent version (e.g. 4.0.29) and include the serenity-browserstack plugin in the dependencies.

kamal-kaur04 commented 10 months ago

@wakaleo Acknowledged. Have tried the suggestion. Still, I'm not getting status updates on the above sample. There are no such errors, plugin seems to be working since it's marking the session name on BrowserStack correctly.

wakaleo commented 10 months ago

Could you try with this repo? https://github.com/serenity-bdd/serenity-todomvc-demo/tree/browserstack

image

(The video camera icon indicates that the BrowserStack integration is working)

image image