-
Notifications
You must be signed in to change notification settings - Fork 6
Running Cucumber Perf
mpinardi edited this page Jan 29, 2020
·
6 revisions
There are multiple ways you can run a test in Cucumber-Perf
java -cp "paths to cucumber-perf and cucumber" cucumber.perf.api.cli.Main [cuke options] [cuke perf options]
Example:
java -cp "*.jar;2.1.1/*" cucumber.perf.api.cli.Main
Create your main.
import cucumber.api.perf.cli.Main;
public class Test {
public static void main(String[] args)
{
try {
Main.main(args);
} catch (Throwable e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//or
CucumberPerf cukePerf = new CucumberPerf(args);
try {
cukePerf.runThreads();
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
a. Build your jar and run from command line.
Your command line options can mix (and is expected to mix) cucumber cli options with cucumber-perf cli options.
Example:
java test.jar plans=src/test/java/resources "tags=not @skip" -g steps src/test/java/resources
b. Use Annotations
You can pass in a class that contains both cucumber and cucumber-perf annotations.
@CucumberOptions(
plugin = {"html:target/cucumber-htmlreport", "json:target/cucumber-report.json" },
features = {"src/test/java/resources"})
@CucumberPerfOptions(
plans = {"src/test/java/resources"},
tags = {"not @bskip","@planPosTest"},
name = {"^(?!.*period).*$"})
public class Test {
public static void main(String[] args)
{
CucumberPerf cukePerf = new CucumberPerf(this.class);
....
}
}
c. Pass in runtime options
The run time options must contain both cucumber and cucumber-perf options
public class Test {
public static void main(String[] args)
{
PerfRuntimeOptions options = new PerfRuntimeOptions();
options.addTagFilters(Arrays.asList(new String[]{"not @bskip","@planPosTest"}));
options.addPlanPaths(Arrays.asList(new String[]{"src/test/java/resources"}));
options.addCucumberOptions(Arrays.asList(new String[]{"-g","steps","src/test/java/resources"}));
CucumberPerf cukePerf = new CucumberPerf(options);
....
}
}
d. Or any combination of the 3 above