Which argument to use for extraGlue option?
cj19 opened this issue · 4 comments
I'd like to register a gradle task to run my integration tests with cucumber. The task definition looks like this:
tasks.register('integrationTest', Test) {
description = 'Runs integration tests.'
group = 'verification'
dependsOn assemble, testClasses
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = [
'--plugin', 'pretty',
'--plugin', 'json:target/cucumber/cucumber.json',
'--plugin', 'org.citrusframework.cucumber.CitrusReporter',
'--tags', '"not @ignore"',
'src/test/resources/features'
]
ignoreExitValue = true
}
}
}
In my project there are no steps definitions, because I use yaks standard library and provided that as an extraGlue cucumber option. Is there any way to include that option in here the task definition(e.g: '--cucumber.extraGlue', 'org.citrusframework.yaks.standard')? As i can see that in the README file this is not supperted yet. Is there any other alternative?
You can use --glue
. And --help
for more documentation.
There is no equivalent of extraGlue
, the java doc on CucumberOptions should be sufficient to explain that.
Leaving this open because it looks like the cucumber-core
read me is missing a section about the CLI.
You can use
--glue
. And--help
for more documentation.There is no equivalent of
extraGlue
, the java doc on CucumberOptions should be sufficient to explain that.Leaving this open because it looks like the cucumber-core read me is missing a section about the CLI.
Thanks for the links. To add more context, my main class looks like this:
@RunWith(Cucumber.class)
@CucumberContextConfiguration
@ContextConfiguration(classes = { CitrusSpringConfig.class, KafkaEndpointConfiguration.class,
EndpointConfiguration.class })
@CucumberOptions(tags = "not @ignore",
features = "src/test/resources/features",
extraGlue = "org.citrusframework.yaks.standard",
plugin = { "pretty", "json:target/cucumber/cucumber.json",
"org.citrusframework.cucumber.CitrusReporter" })
public class RunIntegrationTests {
}
And i have no steps configuration, because as you can see I use the yaks library and further steps configuration is not needed in this project. Obviously running the integration tests using the class cause no problems, but I need a gradle config as well.
I added the
'--glue', 'org.citrusframework.yaks.standard',
into the gradle run config and this was the error I got:
Exception in thread "main" io.cucumber.core.exception.CompositeCucumberException: There were 2 exceptions. The details are in the stacktrace below.
at io.cucumber.core.runtime.RethrowingThrowableCollector.getThrowable(RethrowingThrowableCollector.java:57)
at io.cucumber.core.runtime.CucumberExecutionContext.getThrowable(CucumberExecutionContext.java:109)
at io.cucumber.core.runtime.CucumberExecutionContext.runFeatures(CucumberExecutionContext.java:155)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:78)
at io.cucumber.core.cli.Main.run(Main.java:87)
at io.cucumber.core.cli.Main.main(Main.java:30)
Suppressed: io.cucumber.core.backend.CucumberBackendException: Please annotate a glue class with some context configuration.
For example:
@CucumberContextConfiguration
@SpringBootTest(classes = TestConfig.class)
public class CucumberSpringConfiguration { }
Or:
@CucumberContextConfiguration
@ContextConfiguration( ... )
public class CucumberSpringConfiguration { }
at io.cucumber.spring.SpringFactory.start(SpringFactory.java:102)
at org.citrusframework.cucumber.backend.spring.CitrusSpringObjectFactory.start(CitrusSpringObjectFactory.java:66)
at io.cucumber.core.runner.Runner.buildBackendWorlds(Runner.java:134)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:70)
at io.cucumber.core.runtime.Runtime.lambda$executePickle$6(Runtime.java:107)
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.core.runtime.Runtime.lambda$executePickle$7(Runtime.java:107)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:235)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
at io.cucumber.core.runtime.Runtime.lambda$runFeatures$3(Runtime.java:89)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:200)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at io.cucumber.core.runtime.Runtime.runFeatures(Runtime.java:90)
at io.cucumber.core.runtime.Runtime.lambda$run$0(Runtime.java:78)
at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runFeatures$6(CucumberExecutionContext.java:148)
at io.cucumber.core.runtime.CucumberExecutionContext.execute(CucumberExecutionContext.java:163)
at io.cucumber.core.runtime.CucumberExecutionContext.runFeatures(CucumberExecutionContext.java:146)
... 3 more
Suppressed: io.cucumber.core.backend.CucumberBackendException: Please annotate a glue class with some context configuration.
For example:
@CucumberContextConfiguration
@SpringBootTest(classes = TestConfig.class)
public class CucumberSpringConfiguration { }
Or:
@CucumberContextConfiguration
@ContextConfiguration( ... )
public class CucumberSpringConfiguration { }
I suppose the yaks standard library classes do not have the necessary annotations. I am not sure how can I tackle this problem. Any ideas are appreciated.
As the error explains, you'll need a class with these annotation somewhere on your glue path:
@CucumberContextConfiguration
@ContextConfiguration(classes = { CitrusSpringConfig.class, KafkaEndpointConfiguration.class,
EndpointConfiguration.class })
Note that --glue
can be repeated.
Understood. Now the task can be ran, but as I have no steps configuration (because I use yaks), thus the tests end with undefined step configuration results.
2 Scenarios (2 undefined)
16 Steps (14 skipped, 2 undefined)
How can I integrate yaks steps into this task configuration in order to run the tests properly like I do it with the class config run?
EDIT:
I have figured it out:
'--glue', my.project.library',
'--glue', 'org.citrusframework.yaks.standard',
Using multiple glue path configurations solved the problem. Thank you for help!