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

No default constructor #2663

Closed
rotilho opened this issue Dec 16, 2022 · 2 comments · Fixed by #2664
Closed

No default constructor #2663

rotilho opened this issue Dec 16, 2022 · 2 comments · Fixed by #2664

Comments

@rotilho
Copy link

rotilho commented Dec 16, 2022

👓 What did you see?

Since the upgrade to 7.10.0 Cucumber fails

✅ What did you expect to see?

Work seamless

📦 Which tool/library version are you using?

Spring Boot 2.7.5
JUnit 5
Java 17

🔬 How could we reproduce it?

Steps to reproduce the behavior:

@SpringBootTest
@CucumberContextConfiguration
@RequiredArgsConstructor
public class CucumberConfiguration {
    private final CucumberIssueApplication.MyObject myObject;

}

📚 Any additional context?

io.cucumber.core.backend.CucumberBackendException: Failed to instantiate [com.example.cucumberissue.CucumberConfiguration]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.example.cucumberissue.CucumberConfiguration.<init>()

	at io.cucumber.spring.TestContextAdaptor.createAndPrepareTestInstance(TestContextAdaptor.java:101)
	at io.cucumber.spring.TestContextAdaptor.start(TestContextAdaptor.java:56)
	at io.cucumber.spring.SpringFactory.start(SpringFactory.java:121)
	at io.cucumber.core.runner.Runner.buildBackendWorlds(Runner.java:134)
	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:129)
	at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
	at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:129)
	at io.cucumber.junit.platform.engine.CucumberEngineExecutionContext.runTestCase(CucumberEngineExecutionContext.java:109)
	at io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor.execute(NodeDescriptor.java:164)
	at io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor.execute(NodeDescriptor.java:90)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.suite.engine.SuiteLauncher.execute(SuiteLauncher.java:59)
	at org.junit.platform.suite.engine.SuiteTestDescriptor.execute(SuiteTestDescriptor.java:130)
	at org.junit.platform.suite.engine.SuiteTestEngine.lambda$execute$0(SuiteTestEngine.java:73)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.junit.platform.suite.engine.SuiteTestEngine.execute(SuiteTestEngine.java:73)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.cucumberissue.CucumberConfiguration]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.example.cucumberissue.CucumberConfiguration.<init>()
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:83)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowire(AbstractAutowireCapableBeanFactory.java:397)
	at io.cucumber.spring.TestContextAdaptor.createAndPrepareTestInstance(TestContextAdaptor.java:96)
	... 73 more
Caused by: java.lang.NoSuchMethodException: com.example.cucumberissue.CucumberConfiguration.<init>()
	at java.base/java.lang.Class.getConstructor0(Class.java:3585)
	at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:78)
	... 75 more




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

mpkorstanje added a commit that referenced this issue Dec 16, 2022
… classes

In #2661 classes annotated with `@CucumberContextConfiguration` were created as
beans directly from the bean factory. This allowed them to be prepared as test
instances by JUnit. However, we did not tell the factory that it should
autowire constructor dependencies resulting in #2663.

Additionally, because beans were created directly from the bean factory, they
were not added to the application context. This meant that while dependencies
could be injected into them, they could not be injected into other objects.

Fixes: #2663
mpkorstanje added a commit that referenced this issue Dec 16, 2022
In #2661 classes annotated with `@CucumberContextConfiguration` were created as
beans directly from the bean factory. This allowed them to be prepared as test
instances by JUnit. However, we did not tell the factory that it should
autowire constructor dependencies resulting in #2663.

Additionally, because beans were created directly from the bean factory, they
were not added to the application context. This meant that while dependencies
could be injected into them, they could not be injected into other objects.

Fixes: #2663
mpkorstanje added a commit that referenced this issue Dec 16, 2022
In #2661 classes annotated with `@CucumberContextConfiguration` were created as
beans directly from the bean factory. This allowed them to be prepared as test
instances by JUnit. However, we did not tell the factory that it should
autowire constructor dependencies resulting in #2663.

Additionally, because beans were created directly from the bean factory, they
were not added to the application context. This meant that while dependencies
could be injected into them, they could not be injected into other objects.

Fixes: #2663
mpkorstanje added a commit that referenced this issue Dec 16, 2022
…#2664)

In #2661 classes annotated with `@CucumberContextConfiguration` were created as
beans directly from the bean factory. This allowed them to be prepared as test
instances by JUnit. However, we did not tell the factory that it should
autowire constructor dependencies resulting in #2663.

Additionally, because beans were created directly from the bean factory, they
were not added to the application context. This meant that while dependencies
could be injected into them, they could not be injected into other objects.

Fixes: #2663
@mpkorstanje
Copy link
Contributor

Cheers! Fixed in 7.10.1

@rotilho
Copy link
Author

rotilho commented Dec 17, 2022

Ultra fast fix. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants