/** * Bootstrap the cucumber runtime * * @param clazz Which has the cucumber.api.CucumberOptions and org.testng.annotations.Test annotations */ public CustomTestNGCucumberRunner(Class<?> clazz) { classLoader = clazz.getClassLoader(); resourceLoader = new MultiLoader(classLoader); cucumberFeatures = initCucumberOptions(clazz); resultListener = new FeatureResultListener(runtimeOptions.reporter(classLoader), runtimeOptions.isStrict()); }
public void performInternalCucumberOperations(final Object testInstance, final TEST_NOTIFIER runNotifier) throws Exception { final Class<?> javaTestClass = getTestedClass(); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final InputStream configurationInputStream = classLoader.getResourceAsStream(ClientServerFiles.CONFIG); final Properties cukespaceConfigurationProperties = loadCucumberConfigurationProperties(configurationInputStream); final RuntimeOptions runtimeOptions = loadRuntimeOptions(javaTestClass, cukespaceConfigurationProperties); final boolean reported = Boolean.parseBoolean(cukespaceConfigurationProperties.getProperty(CucumberConfiguration.REPORTABLE, "false")); final StringBuilder reportBuilder = new StringBuilder(); if (reported) { runtimeOptions.addPlugin(new JSONFormatter(reportBuilder)); } final InputStream gluesInputStream = classLoader.getResourceAsStream(ClientServerFiles.GLUES_LIST); final Collection<Class<?>> glues = loadGlues(gluesInputStream, classLoader, javaTestClass); final ArquillianBackend arquillianBackend = new ArquillianBackend( glues, javaTestClass, testInstance, cukespaceConfigurationProperties.getProperty(CucumberConfiguration.OBJECT_FACTORY)); final CucumberRuntime cucumberRuntime = new CucumberRuntime(null, classLoader, singletonList(arquillianBackend), runtimeOptions); final Map<String, Collection<URL>> featuresMap = Features.createFeatureMap(CucumberConfiguration.instance().getTempDir(), cukespaceConfigurationProperties.getProperty(CucumberConfiguration.FEATURE_HOME), javaTestClass, classLoader); final List<CucumberFeature> cucumberFeatures = getCucumberFeatures(runtimeOptions.getFilters(), testInstance, classLoader, featuresMap); final Formatter formatter = runtimeOptions.formatter(classLoader); final Reporter reporter = runtimeOptions.reporter(classLoader); final StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader); cucumberRuntime.getGlue().reportStepDefinitions(stepDefinitionReporter); runFeatures(cucumberFeatures, cucumberRuntime, getReporter(reporter, formatter, runtimeOptions), runNotifier); if (reported) { final String path = cukespaceConfigurationProperties.getProperty(CucumberConfiguration.REPORTABLE_PATH); addReportTestIntoFile(path, javaTestClass, reportBuilder); } handleCucumberTestErrors(cucumberRuntime.getErrors(), cucumberRuntime); }
/** * 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"); System.setProperty(AssertionFacade.ASSERTION_FACADE, AssertionFacadeLoadRunnerImpl.class.getCanonicalName()); System.setProperty(VariableFacade.VARIABLE_FACADE, VariableFacadeLoadRunnerImpl.class.getCanonicalName()); 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); }
RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); reporter = runtimeOptions.reporter(classLoader); formatter = runtimeOptions.formatter(classLoader); isStrict = runtimeOptions.isStrict();
RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); reporter = runtimeOptions.reporter(classLoader); formatter = runtimeOptions.formatter(classLoader); isStrict = runtimeOptions.isStrict();
private void init(RuntimeOptions runtimeOptions, ClassLoader classLoader, ResourceLoader resourceLoader) throws Exception { for (ExtendedRuntimeOptions option : extendedOptions) { retryCount = Math.max(retryCount, option.getRetryCount()); threadsCount = Math.max(threadsCount, option.getThreadsCount()); } final JUnitOptions junitOptions = new JUnitOptions(runtimeOptions.getJunitOptions()); final List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader); jUnitReporter = new JUnitReporter( runtimeOptions.reporter(classLoader), runtimeOptions.formatter(classLoader), runtimeOptions.isStrict(), junitOptions); Method[] retryMethods = this.getPredefinedMethods(RetryAcceptance.class); addChildren(cucumberFeatures, retryMethods); } protected Runtime createRuntime(ResourceLoader resourceLoader, ClassLoader classLoader,
/** * 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); }