-
-
Notifications
You must be signed in to change notification settings - Fork 2k
ParameterType values not resolved when cucumber is run from a fat jar #2146
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
Comments
In your reproducer you are using both Cucumber uses Java's Service Provider Interfaces to register backend implementations and it would appear that only the Java 8 Backend implementation is loaded but not the Java backend. And indeed, if we look at the contents of the fat-jar we can see that the service registrations are overlapping rather then merged:
You'll have to fix the process by which you create a fat jar. |
Note: If you are using shadow you may also have to use Though I'm surprised it is not enabled by default. |
Many thanks for the quick reply! This makes a lot of sense. Merging the service files did the trick. The reason for including both I didn't see that these implementations should be mutually exclusive, as we've had good luck mixing classic and lambda style step defs. Some of our projects are quite large (and old) and added lambda style step defs when they were introduced, but never fully updated the old definitions. If it is not recommended to mix, it'd be nice to only need to consume one dependency or the other. |
You can mix them just fine. However minimizing the components involved is a the part of creating and MCVE that usually allows you to discover the problem on your own. There should also be a lambda equivalent of Parameter type. Though beware of: |
Describe the bug
When a cucumber project is packaged into a standard fat or uber jar, parameter types are not registered properly and fail during execution. If parameter types are not used or the application is run by adding cucumber jars to the classpath, this works correctly and cucumber can be executed via a fat jar.
To Reproduce
Steps to reproduce the behavior:
I have provided a simple example built with gradle here: https://github.com/mjbingen/cucumber-sandbox/tree/fatjar-bug
SEVERE: Exception while executing pickle
java.util.concurrent.ExecutionException: io.cucumber.core.exception.CucumberException: Could not create a cucumber expression for 'we have {triple}'.
It appears you did not register a parameter type.
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:93)
at io.cucumber.core.cli.Main.run(Main.java:92)
at io.cucumber.core.cli.Main.main(Main.java:34)
at com.foo.RunCukes.main(RunCukes.java:23)
Note that the code on the master branch of this repo does not have the ParameterType definition and runs just fine from the fat jar.
Expected behavior
The packaged cucumber application should execute and resolve parameter type definitions whether glue code is added to the classpath or directly embedded into a fat jar executable jar.
Context & Motivation
While packaging a cucumber based app as a "java application" is relatively easy in maven/gradle, it still requires managing all the dependent jars and runtime scripts to set classpaths properly. Sometimes when deploying a test binary to many environments its helpful just to have a fat jar that can be executed.
Your Environment
Additional context
I've tried things like shadow (https://github.com/johnrengelman/shadow) and manual jar creation, but the issue persists. This could be somewhat related to the issue with Spring Jars (#1931) but know they are special in their embedding structure. This is more around the difference between loading jars via classpath vs. embedded in the runnable jar.
The text was updated successfully, but these errors were encountered: