cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

Hooks does not have a public zero-argument constructor error is thrown after upgrading cucumber version from 7.3.4 to 7.9.0 #2682

Closed MadhuQAAutomation closed 1 year ago

MadhuQAAutomation commented 1 year ago

šŸ‘“ What did you see?

Note : This is happening only running through jenkins.

Our test automation framework is built with dependency injection using the pico-container. Recently I upgraded the cucumber dependencies to v 7.9.0. After upgradation, when I run the jenkins job, the build is failed with the below exception:

Running runner.TestRunner @EnvironmentConfigs 11:17:03 Scenario: Add properties # src/test/resources/features/config-setup/EnvironmentPreRequsites.feature:5 11:17:03 io.cucumber.core.exception.CucumberException: class com.test.glue.Hooks does not have a public zero-argument constructor. 11:17:03 To use dependency injection add an other ObjectFactory implementation such as: 11:17:03 cucumber-picocontainer 11:17:03 cucumber-spring 11:17:03 cucumber-jakarta-cdi 11:17:03 ...etc 11:17:03 at io.cucumber.core.backend.DefaultObjectFactory.cacheNewInstance(DefaultObjectFactory.java:57) 11:17:03 at io.cucumber.core.backend.DefaultObjectFactory.getInstance(DefaultObjectFactory.java:45) 11:17:03 at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47) 11:17:03 at io.cucumber.java.JavaHookDefinition.execute(JavaHookDefinition.java:64) 11:17:03 at io.cucumber.core.runner.CoreHookDefinition.execute(CoreHookDefinition.java:46) 11:17:03 at io.cucumber.core.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:21) 11:17:03 at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10) 11:17:03 at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:85)

We have written the most commonly used step definitions in a different project, converted it as a jar and used in this project. Both the projects uses Hooks and Context, but with different names. Current project extends the Hooks and Context classes for inheritance.

āœ… What did you expect to see?

Cucumber should not through the exception and the test should get executed. As I mentioned, when we run the same in local, its working fine. Issue is observed only while running from Jenkins. Note : I have checked the dependencies in jenkins and all the required dependencies are available.

šŸ“¦ Which tool/library version are you using?

Cucumber -7.9.0 Maven -3.8.6

šŸ”¬ How could we reproduce it?

Steps to reproduce the behavior:

  1. Install '...' version '...'
  2. Create a file called '....'
  3. Run command '....'
  4. See error '....'

šŸ“š Any additional context?


This text was originally generated from a template, then edited by hand. You can modify the template here.

mpkorstanje commented 1 year ago

With the information you've provided it is impossible to reproduce your problem. Please have a look at How to create a Minimal, Reproducible Example for guidance.

It may also help if you van pinpoint exactly which version included the breaking change.

MadhuQAAutomation commented 1 year ago

Hi - I checked the versions from 7.3.4 till 7.8.0 and it was working fine. Error is getting displayed for version 7.9.0.

qa-test-automation.zip

mpkorstanje commented 1 year ago

I'm disappointed to see that you've not followed the guidance on creating a minimal example. Your reproducer is anything but minimal. If you can not provide a minimal example it is impossible to help you. The cucumber-java-skeleton would be a good starting point should you need it.

I also see that you are using Courgette-JVM to run your tests rather than Cucumber-JVM. If your problem can not be reproduced without this dependency you should create an issue there instead.

MadhuQAAutomation commented 1 year ago

Ok.. Thank you!