本文整理汇总了Java中cucumber.runtime.RuntimeOptions类的典型用法代码示例。如果您正苦于以下问题:Java RuntimeOptions类的具体用法?Java RuntimeOptions怎么用?Java RuntimeOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeOptions类属于cucumber.runtime包,在下文中一共展示了RuntimeOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CucumberLoadRunner
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
/**
* Constructor called by JUnit.
*
* @param clazz the class with the @RunWith annotation.
* @throws java.io.IOException if there is a problem
* @throws org.junit.runners.model.InitializationError if there is another problem
*/
public CucumberLoadRunner(Class clazz) throws InitializationError, IOException {
super(clazz);
System.setProperty(cukesProperty(CONTEXT_INFLATING_ENABLED), "false");
System.setProperty(cukesProperty(ASSERTIONS_DISABLED), "true");
System.setProperty(cukesProperty(LOADRUNNER_FILTER_BLOCKS_REQUESTS), "true");
filter = SingletonObjectFactory.instance().getInstance(LoadRunnerFilter.class);
ClassLoader classLoader = clazz.getClassLoader();
Assertions.assertNoCucumberAnnotatedMethods(clazz);
RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz);
RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
ResourceLoader resourceLoader = new MultiLoader(classLoader);
runtime = createRuntime(resourceLoader, classLoader, runtimeOptions);
final List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader);
jUnitReporter = new JUnitReporter(runtimeOptions.reporter(classLoader),
runtimeOptions.formatter(classLoader), runtimeOptions.isStrict(), new JUnitOptions(runtimeOptions.getJunitOptions()));
addChildren(cucumberFeatures);
}
示例2: getRuntime
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
public Runtime getRuntime(List<String> additionalCucumberArguments) {
List<String> runtimeCucumberArguments = new ArrayList<String>(runtimeConfiguration.cucumberPassthroughArguments);
runtimeCucumberArguments.addAll(additionalCucumberArguments);
RuntimeOptions runtimeOptions = new RuntimeOptions(runtimeCucumberArguments);
ResourceLoader resourceLoader = getResourceLoader();
Runtime runtime = null;
if (runtimeConfiguration.threadTimelineReportRequired){
runtime = createThreadLoggedRuntime(runtimeOptions, resourceLoader);
} else {
runtime = createDefaultRuntime(runtimeOptions, resourceLoader);
}
return runtime;
}
示例3: testLoadGlue
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
public void testLoadGlue() throws Throwable {
RemoteBackend remoteBackend = new RemoteBackend(REST_BASE_URL, restTemplate);
final CucumberFeature feature = TestHelper.feature("nice.feature", join(
"Feature: Be nice",
"",
"Scenario: Say hello to Cucumber",
"When I say hello to Cucumber",
"And I say hello to:",
"| name | gender |",
"| John | MALE |",
"| Mary | FEMALE |"));
RuntimeOptions runtimeOptions = new RuntimeOptions(Arrays.asList(
"--glue", "cucumber.runtime.remote.stepdefs",
"--plugin", "pretty",
"--monochrome"
)) {
@Override
public List<CucumberFeature> cucumberFeatures(ResourceLoader resourceLoader) {
return Collections.singletonList(feature);
}
};
Runtime runtime = new Runtime(resourceLoader, classLoader, Collections.singletonList(remoteBackend), runtimeOptions);
runtime.run();
}
示例4: execute
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
before();
try {
final RuntimeOptions runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm", System.getProperties()), args());
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ResourceLoader resourceLoader = new MultiLoader(classLoader);
final ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
final Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
runtime.writeStepdefsJson();
runtime.run();
runtime.getErrors();
if (runtime.exitStatus() != 0) {
throw new MojoExecutionException("Got non-zero exit status " + runtime.exitStatus());
}
} catch (final IOException e) {
throw new MojoExecutionException("Failure to write Json Stepdefs during Cucumber-JVM run", e);
} finally {
after();
}
}
示例5: onCreate
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
@Override
public void onCreate(Bundle arguments) {
Context context = getContext();
Properties properties = new Properties();
String glue = context.getPackageName();
String features = "features";
properties.setProperty("cucumber.options", String.format("-g %s %s", glue, features));
mRuntimeOptions = new RuntimeOptions(properties);
mResourceLoader = new AndroidResourceLoader(context);
List<Backend> backends = new ArrayList<Backend>();
backends.add(new AndroidBackend(this));
mRuntime = new Runtime(mResourceLoader, getLoader(), backends, mRuntimeOptions);
mFormatter = new AndroidFormatter(TAG);
mRuntimeOptions.formatters.clear();
mRuntimeOptions.formatters.add(mFormatter);
super.onCreate(arguments);
}
示例6: setUpClass
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
@BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
runtimeOptions = new KarateRuntimeOptions(getClass());
TestNgReporter reporter = new TestNgReporter(System.out);
RuntimeOptions ro = runtimeOptions.getRuntimeOptions();
resultListener = new FeatureResultListener(ro.reporter(runtimeOptions.getClassLoader()), ro.isStrict());
}
示例7: tearDownClass
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
@AfterClass(alwaysRun = true)
public void tearDownClass() throws Exception {
RuntimeOptions ro = runtimeOptions.getRuntimeOptions();
Formatter formatter = ro.formatter(runtimeOptions.getClassLoader());
formatter.done();
formatter.close();
}
示例8: getCucumberFeatures
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
public List<CucumberFeature> getCucumberFeatures() {
final CourgetteRuntimeOptions courgetteRuntimeOptions = new CourgetteRuntimeOptions(courgetteProperties);
final List<String> argv = Arrays.asList(courgetteRuntimeOptions.getRuntimeOptions());
runtimeOptions = new RuntimeOptions(argv);
cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader);
return cucumberFeatures;
}
示例9: cucumberScenarios
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
private Map<CucumberFeature, Integer> cucumberScenarios(List<CucumberFeature> cucumberFeatures, RuntimeOptions runtimeOptions) {
final Map<CucumberFeature, Integer> scenarios = new HashMap<>();
if (cucumberFeatures != null) {
cucumberFeatures.forEach(cucumberFeature -> cucumberFeature.getFeatureElements().forEach(featureElement -> {
final List<Integer> lineIds = new ArrayList<>();
if (featureElement instanceof CucumberScenarioOutline) {
((CucumberScenarioOutline) featureElement).getCucumberExamplesList()
.forEach(c -> c.getExamples().getRows().stream().skip(1).forEach(row -> {
lineIds.add(row.getLine());
}));
} else {
lineIds.add(featureElement.getGherkinModel().getLine());
}
lineIds.forEach(lineId -> {
final AtomicBoolean alreadyAdded = new AtomicBoolean(Boolean.FALSE);
runtimeOptions.getFeaturePaths().forEach(resourcePath -> {
if (!alreadyAdded.get()) {
final List<String> scenarioPath = new ArrayList<>();
addScenario(scenarioPath, cucumberFeature, resourcePath, lineId);
try {
scenarios.put(
CucumberFeature.load(resourceLoader, scenarioPath, new ArrayList<>()).stream().findFirst().orElse(null),
lineId);
alreadyAdded.set(Boolean.TRUE);
} catch (IllegalArgumentException e) {
alreadyAdded.set(Boolean.FALSE);
}
}
});
});
}));
}
return scenarios;
}
示例10: getTags
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
@Override
protected String[] getTags(ITestResult testResult) {
RuntimeOptions cucumberOptions = getCucumberOptions(testResult);
List<String> optionsList = cucumberOptions.getFilters().stream().map(object -> Objects.toString(object, null)).collect(Collectors.toList());
optionsList.addAll(cucumberOptions.getFeaturePaths());
optionsList.addAll(cucumberOptions.getGlue());
return ArrayUtils.addAll(super.getTags(testResult), optionsList.toArray(new String[optionsList.size()]));
}
示例11: getCucumberOptions
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
private RuntimeOptions getCucumberOptions(ITestResult testResult) {
try {
return new RuntimeOptionsFactory(Class.forName(testResult.getTestClass().getName())).create();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
示例12: EscCucumber
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
/**
* Constructor called by JUnit.
*
* @param clazz
* the class with the @RunWith annotation.
* @throws java.io.IOException
* if there is a problem
* @throws org.junit.runners.model.InitializationError
* if there is another problem
*/
public EscCucumber(Class<?> clazz) throws InitializationError, IOException {
super(clazz);
ClassLoader classLoader = clazz.getClassLoader();
Assertions.assertNoCucumberAnnotatedMethods(clazz);
final List<String> argList = new ArrayList<String>();
final EscCucumberArgs args = clazz.getAnnotation(EscCucumberArgs.class);
if (args == null) {
argList.add("NONE");
} else {
argList.addAll(EscSpiUtils.asList(args.value()));
}
RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(
clazz);
RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
ResourceLoader resourceLoader = new MultiLoader(classLoader);
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader,
classLoader);
runtime = new Runtime(resourceLoader, classFinder, classLoader,
runtimeOptions);
jUnitReporter = new JUnitReporter(runtimeOptions.reporter(classLoader),
runtimeOptions.formatter(classLoader),
runtimeOptions.isStrict());
for (final String arg : argList) {
addChildren(runtimeOptions.cucumberFeatures(resourceLoader), arg);
}
}
示例13: createDefaultRuntime
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
private Runtime createDefaultRuntime(RuntimeOptions runtimeOptions, ResourceLoader resourceLoader) {
if (cucumberBackendFactory == null) {
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, cucumberClassLoader);
return new Runtime(resourceLoader, classFinder, cucumberClassLoader, runtimeOptions);
} else {
return new Runtime(resourceLoader, cucumberClassLoader, cucumberBackendFactory.getBackends(), runtimeOptions);
}
}
示例14: createThreadLoggedRuntime
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
private Runtime createThreadLoggedRuntime(RuntimeOptions runtimeOptions, ResourceLoader resourceLoader) {
if (cucumberBackendFactory == null) {
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, cucumberClassLoader);
return new ThreadLoggedRuntime(resourceLoader, classFinder, cucumberClassLoader, runtimeOptions, threadExecutionRecorder);
} else {
return new ThreadLoggedRuntime(resourceLoader, cucumberClassLoader, cucumberBackendFactory.getBackends(), runtimeOptions, threadExecutionRecorder);
}
}
示例15: getRuntime
import cucumber.runtime.RuntimeOptions; //导入依赖的package包/类
@Override
public synchronized Runtime getRuntime(List<String> additionalCucumberArgs) {
RuntimeOptions runtimeOptions = new RuntimeOptions(additionalCucumberArgs);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ResourceLoader resourceLoader = new MultiLoader(classLoader);
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
byte exitCode = perInvocationExitCodes[invocationCount % perInvocationExitCodes.length];
boolean shouldThrowException = perInvocationShouldThrowException[invocationCount % perInvocationExitCodes.length];
invocationCount++;
ThreadExecutionRecorder threadExecutionRecorder = new ThreadExecutionRecorder();
return new FakeCucumberRuntime(exitCode, shouldThrowException, resourceLoader, classFinder, classLoader, runtimeOptions, threadExecutionRecorder);
}