本文整理汇总了Java中cucumber.runtime.ClassFinder类的典型用法代码示例。如果您正苦于以下问题:Java ClassFinder类的具体用法?Java ClassFinder怎么用?Java ClassFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassFinder类属于cucumber.runtime包,在下文中一共展示了ClassFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testContextConfiguration
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
private void testContextConfiguration(String profile, String springProfile) {
GenericXmlApplicationContext context = createContext(profile, springProfile);
AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ResourceLoader resourceLoader = new MultiLoader(classLoader);
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
Collection<Class<?>> descendants = classFinder.getDescendants(Object.class, "com.hotwire.test.steps");
List<Throwable> throwables = new ArrayList<>();
for (Class<?> clazz : descendants) {
if (Utils.isInstantiable(clazz) & !clazz.isEnum()) {
context.registerBeanDefinition(clazz.getName(),
BeanDefinitionBuilder.genericBeanDefinition(clazz).getBeanDefinition());
try {
factory.getBean(clazz.getName());
}
catch (Throwable t) {
while (t.getCause() != null) {
t = t.getCause();
}
System.err.println(t.getMessage());
throwables.add(t);
}
}
}
assertThat(throwables)
.as("List of throwables should be empty!")
.isEmpty();
}
示例2: execute
import cucumber.runtime.ClassFinder; //导入依赖的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();
}
}
示例3: EscCucumber
import cucumber.runtime.ClassFinder; //导入依赖的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);
}
}
示例4: createDefaultRuntime
import cucumber.runtime.ClassFinder; //导入依赖的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);
}
}
示例5: createThreadLoggedRuntime
import cucumber.runtime.ClassFinder; //导入依赖的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);
}
}
示例6: getRuntime
import cucumber.runtime.ClassFinder; //导入依赖的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);
}
示例7: FakeCucumberRuntime
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
public FakeCucumberRuntime(byte exitCode, boolean shouldThrowExceptionOnRun, ResourceLoader resourceLoader,
ClassFinder classFinder, ClassLoader classLoader, RuntimeOptions runtimeOptions,
ThreadExecutionRecorder threadExecutionRecorder) {
super(resourceLoader, classFinder, classLoader, runtimeOptions, threadExecutionRecorder);
this.exitCode = exitCode;
this.shouldThrowExceptionOnRun = shouldThrowExceptionOnRun;
}
示例8: execute
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
public void execute(ClassLoader classLoader, ResultCollector rc) {
ResourceLoader resourceLoader = new MultiLoader(classLoader);
// TODO threadlocal runtime cache using junitTestClass as a key
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(junitTestClass);
RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
Reporter reporter = new ReporterAdapter(rc, getDescription());
LOGGER.fine("Executing cucumber \"" + scenario.getVisualName() + "\"");
scenario.run(nullFormatter(), reporter, runtime);
}
示例9: CucumberRunner
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
@Test(groups = "cucumber", description = "Runs Cucumber Features")
public void CucumberRunner() throws Throwable {
ClassLoader classLoader = getClass().getClassLoader();
ResourceLoader resourceLoader = new MultiLoader(classLoader);
RuntimeOptionsFactory roFactory = new RuntimeOptionsFactory(getClass());
RuntimeOptions ro = roFactory.create();
ro.getGlue().clear();
ro.getGlue().add("classpath:");
ro.getFeaturePaths().clear();
ro.getFeaturePaths().add(feature);
if (!tags.isEmpty()) {
for (String s : tags.split("--tags")) {
if (!s.trim().isEmpty()) {
ro.getFilters().add(s.trim());
}
}
}
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
runtime = new cucumber.runtime.Runtime(resourceLoader, classFinder, classLoader, ro);
try {
ReporterNGExt.logBusiness(String.format("Run Feature - %s", feature));
runtime.run();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
if (!runtime.getErrors().isEmpty()) {
ReporterNGExt.logBusiness(runtime.getErrors().toString());
throw new CucumberException(runtime.getErrors().get(0));
}
}
示例10: KarateBackend
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
public KarateBackend(ScriptEnv env, CallContext callContext) {
this.callContext = callContext;
ClassFinder classFinder = new KarateClassFinder(env.fileClassLoader);
objectFactory = new KarateObjectFactory(env, callContext);
backend = new JavaBackend(objectFactory, classFinder);
}
示例11: createRuntime
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
private Runtime createRuntime(RuntimeOptions runtimeOptions) {
final ResourceLoader resourceLoader = new MultiLoader(classLoader);
final ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
return new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
}
示例12: ThreadLoggedRuntime
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
public ThreadLoggedRuntime(ResourceLoader resourceLoader, ClassFinder classFinder, ClassLoader classLoader,
RuntimeOptions runtimeOptions, ThreadExecutionRecorder threadExecutionRecorder) {
super(resourceLoader, classFinder, classLoader, runtimeOptions);
this.threadExecutionRecorder = threadExecutionRecorder;
}
示例13: RestRuntime
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
public RestRuntime(ResourceLoader resourceLoader, ClassFinder classFinder,
ClassLoader classLoader, RuntimeOptions runtimeOptions) {
runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
results = new ArrayList<CucumberFeatureResultContainer>();
}
示例14: classFinder
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
@Bean
public ClassFinder classFinder() {
return new ResourceLoaderClassFinder(resourceLoader(), classLoader);
}
示例15: createRuntime
import cucumber.runtime.ClassFinder; //导入依赖的package包/类
/**
* Create the RestRuntime. Can be overridden to customize the runtime or backend.
* @param resourceLoader used to load resources
* @param classLoader used to load classes
* @param runtimeOptions configuration
* @return a new runtime
* @throws InitializationError if a JUnit error occurred
* @throws IOException if a class or resource could not be loaded
*/
protected RestRuntime createRuntime(ResourceLoader resourceLoader,
ClassLoader classLoader, RuntimeOptions runtimeOptions) throws InitializationError,
IOException {
ClassFinder classFinder =
new ResourceLoaderClassFinder(resourceLoader, classLoader);
return new RestRuntime(resourceLoader, classFinder, classLoader, runtimeOptions);
}