Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kamal-kaur04 opened this issue Nov 7, 2023 · 6 comments

Comments

@kamal-kaur04
Copy link
Contributor

kamal-kaur04 commented Nov 7, 2023

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

  • Mac M2
  • Running on BrowserStack
  • No

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
Copy link
Contributor Author

kamal-kaur04 commented Nov 8, 2023

@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
Copy link
Member

wakaleo commented Nov 17, 2023

Here is what I could find:

  • There are several dependency conflicts:
    - webdriver-overload uses an older version of Selenium (you need to update the library)
    - Use the latest version of Selenium (currently 4.0.21)
    - Use the latest lombok version (currently 1.18.30)
  • You are also using a custom driver, which is not recommended as it is harder to maintain and means you cannot use the standard Selenium browserstack plugin or the W3C configurations in the serenity.conf file.

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
Copy link
Contributor Author

@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
Copy link
Member

wakaleo commented Dec 16, 2023

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
Copy link
Contributor Author

@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
Copy link
Member

wakaleo commented Dec 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants