-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
misleading message when SpringFactory doesn't start correctly #2584
Comments
It doesn't look like you're doing anything wrong. Would I have to anything aside from your example code to reproduce the problem?
Yes. Provided |
I've pushed the code in https://github.com/vincent-fuchs/cucumber-jvm-2584 Cucumber version is defined here : https://github.com/vincent-fuchs/cucumber-jvm-2584/blob/main/build.gradle#L65 , you can see that when upgrading to 7.4.1 , the error message is different. I am actuallw struggling to fix the issue at startup with 7.3.4 :
I wrote an equivalent test with cucumber-java instead of cucumber-java8, and I didn't have the problem.. so maybe it comes ffrom cucumber-java8 ? |
Thanks for the reproducer. That made things easy. You've annotated a lambda step definitions with a context configuration. Cucumber uses this class to start the spring application. Cucumber also has to create an instance of this class to provide to springs test context manager framework. This instance must be created before the This is partially due to the impedance mismatch but also yet another reason for #2279. Registering steps at runtime causes all sorts of problemens. As a workaround consider putting the context configuration on it's own class. |
As a fix I'd consider
|
Thanks a lot for the pointer to the workaround ! |
👓 What did you see?
Using Cucumber BOM 7.4.1 on a Spring Boot 2.7 project, I am launching my cucumber test. I see the Spring Context loading, but then the test fails and I get a long stacktrace :
After investigating in debug mode, I realized my scenario is found, and I am entering in the glue-code, but failing immediately :
using DataTableType here actually throws an
InvocationTargetException
:This code used to work with previous versions, and that's fine, I will change it.
But the message we are getting by default is really misleading (and I just spent 2h to understand what was wrong)
✅ What did you expect to see?
The exception that is thrown should be seen in the logs, but it's not : the system is in an inconsistent state, and this is caught at the end, providing an error message that is totally unrelated with the actual issue.
📦 Which tool/library version are you using?
in
io.cucumber.core.runner.Runner
7.4.1 , I see :The exception is thrown by the call to
buildBackendWorlds
. Is it normal that there's no catch block and that we directly go to the finally block ? I would say that having a catch block would enable to log the original exception, and lead the developer directly in the right direction.🔬 How could we reproduce it?
I guess with any glue code that throws some Exception at instantiation time..
📚 Any additional context?
with
v7.3.4
orv7.2.3
, my test also fails, but I get a proper error message that tells me what is wrong :The text was updated successfully, but these errors were encountered: