/** * Bootstrap the cucumber runtime * * @param clazz Which has the cucumber.api.CucumberOptions and org.testng.annotations.Test annotations */ public TestNGCucumberRunner(Class clazz) { ClassLoader classLoader = clazz.getClassLoader(); ResourceLoader resourceLoader = new MultiLoader(classLoader); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); runtimeOptions = runtimeOptionsFactory.create(); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); BackendModuleBackendSupplier backendSupplier = new BackendModuleBackendSupplier(resourceLoader, classFinder, runtimeOptions); bus = new TimeServiceEventBus(TimeService.SYSTEM); new Plugins(classLoader, new PluginFactory(), bus, runtimeOptions); FeatureLoader featureLoader = new FeatureLoader(resourceLoader); filters = new Filters(runtimeOptions); this.runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier); featureSupplier = new FeaturePathFeatureSupplier(featureLoader, runtimeOptions); }
private List<Plugin> createPlugins() { List<Plugin> plugins = new ArrayList<Plugin>(); if (!pluginNamesInstantiated) { for (String pluginName : pluginOptions.getPluginNames()) { Plugin plugin = pluginFactory.create(pluginName); addPlugin(plugins, plugin); } pluginNamesInstantiated = true; } return plugins; }
private <T extends Plugin> T instantiate(String pluginString, Class<T> pluginClass, String argument) throws IOException, URISyntaxException { Constructor<T> single = findSingleArgConstructor(pluginClass); Constructor<T> empty = findEmptyConstructor(pluginClass); if (single != null) { Object ctorArg = convertOrNull(argument, single.getParameterTypes()[0], pluginString); if (ctorArg != null) return newInstance(single, ctorArg); } if (argument == null && empty != null) { return newInstance(empty); } if (single != null) throw new CucumberException(String.format("You must supply an output argument to %s. Like so: %s:output", pluginString, pluginString)); throw new CucumberException(String.format("%s must have a constructor that is either empty or a single arg of one of: %s", pluginClass, asList(CTOR_PARAMETERS))); }
PluginFactory pluginFactory = new PluginFactory(); for (String format : reportformatList) { Object formatObj = pluginFactory.create(format); runtimeOptions.addPlugin(formatObj);
private Object convertOrNull(String arg, Class ctorArgClass, String formatterString) throws IOException, URISyntaxException { if (arg == null) { if (ctorArgClass.equals(Appendable.class)) { return defaultOutOrFailIfAlreadyUsed(formatterString); } else { return null; } } if (ctorArgClass.equals(URI.class)) { return new URI(arg); } if (ctorArgClass.equals(URL.class)) { return toURL(arg); } if (ctorArgClass.equals(File.class)) { return new File(arg); } if (ctorArgClass.equals(String.class)) { return arg; } if (ctorArgClass.equals(Appendable.class)) { return new UTF8OutputStreamWriter(new URLOutputStream(toURL(arg))); } return null; }
PluginFactory pluginFactory = new PluginFactory(); for (String format : reportformatList) { Object formatObj = pluginFactory.create(format); runtimeOptions.addPlugin(formatObj);
public Runtime build() { final ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader : new MultiLoader(this.classLoader); final ClassFinder classFinder = this.classFinder != null ? this.classFinder : new ResourceLoaderClassFinder(resourceLoader, this.classLoader); final BackendSupplier backendSupplier = this.backendSupplier != null ? this.backendSupplier : new BackendModuleBackendSupplier(resourceLoader, classFinder, this.runtimeOptions); final Plugins plugins = new Plugins(this.classLoader, new PluginFactory(), this.eventBus, this.runtimeOptions); for (final Plugin plugin : additionalPlugins) { plugins.addPlugin(plugin); } final RunnerSupplier runnerSupplier = runtimeOptions.isMultiThreaded() ? new ThreadLocalRunnerSupplier(this.runtimeOptions, eventBus, backendSupplier) : new SingletonRunnerSupplier(this.runtimeOptions, eventBus, backendSupplier); final ExecutorService executor = runtimeOptions.isMultiThreaded() ? Executors.newFixedThreadPool(runtimeOptions.getThreads()) : new SameThreadExecutorService(); final FeatureLoader featureLoader = new FeatureLoader(resourceLoader); final FeatureSupplier featureSupplier = this.featureSupplier != null ? this.featureSupplier : new FeaturePathFeatureSupplier(featureLoader, this.runtimeOptions); final Filters filters = new Filters(this.runtimeOptions); return new Runtime(plugins, this.runtimeOptions, eventBus, filters, runnerSupplier, featureSupplier, executor); } }
BackendSupplier backendSupplier = new BackendModuleBackendSupplier(resourceLoader, classFinder, runtimeOptions); this.bus = new TimeServiceEventBus(TimeService.SYSTEM); Plugins plugins = new Plugins(classLoader, new PluginFactory(), bus, runtimeOptions); this.runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier); this.filters = new Filters(runtimeOptions);
public MiniumRunTimeOptions(String argv) { super(new PluginFactory(), Shellwords.parse(argv)); }
public Runtime build() { if (classLoader == null) classLoader = testClass == null ? Thread.currentThread().getContextClassLoader() : testClass.getClassLoader(); if (resourceLoader == null) resourceLoader = new MultiLoader(classLoader); if (pluginFactory == null) pluginFactory = new PluginFactory(); if (runtimeOptions == null) { Preconditions.checkArgument(!args.isEmpty() || testClass != null, "RuntimeOptions not provided, need args or testClass"); runtimeOptions = args.isEmpty() ? new RuntimeOptionsFactory(testClass).create() : new RuntimeOptions(pluginFactory, args); } runtimeOptions.getFeaturePaths().addAll(featurePaths); for (Object plugin : plugins) { runtimeOptions.addPlugin(plugin); } String progressOutputFilePath = System.getProperty("minium.cucumber.progressOutputFile", null); if (progressOutputFilePath != null) { File progressOutputFile = new File(progressOutputFilePath); runtimeOptions.addPlugin(new ProgressFormatter(progressOutputFile)); } runtime = new Runtime(resourceLoader, classLoader, backends, runtimeOptions); return runtime; }
/** * Bootstrap the cucumber runtime * * @param clazz Which has the cucumber.api.CucumberOptions and org.testng.annotations.Test annotations */ public TestNGCucumberRunner(Class clazz) { ClassLoader classLoader = clazz.getClassLoader(); ResourceLoader resourceLoader = new MultiLoader(classLoader); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); runtimeOptions = runtimeOptionsFactory.create(); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); BackendModuleBackendSupplier backendSupplier = new BackendModuleBackendSupplier(resourceLoader, classFinder, runtimeOptions); bus = new TimeServiceEventBus(TimeService.SYSTEM); new Plugins(classLoader, new PluginFactory(), bus, runtimeOptions); FeatureLoader featureLoader = new FeatureLoader(resourceLoader); filters = new Filters(runtimeOptions); this.runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier); featureSupplier = new FeaturePathFeatureSupplier(featureLoader, runtimeOptions); }
this.junitOptions = new JUnitOptions(runtimeOptions.isStrict(), runtimeOptions.getJunitOptions()); Plugins plugins = new Plugins(classLoader, new PluginFactory(), bus, runtimeOptions); final StepDefinitionReporter stepDefinitionReporter = plugins.stepDefinitionReporter();