Package cucumber.runtime

Examples of cucumber.runtime.RuntimeOptions


        if (cucumberFeatures.isEmpty()) {
            throw new IllegalArgumentException("No feature found");
        }

        final RuntimeOptions runtimeOptions;
        if (clazz.getAnnotation(Cucumber.Options.class) != null || clazz.getAnnotation(CucumberOptions.class) != null) { // by class setting
            final RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz, OPTIONS_ANNOTATIONS);
            runtimeOptions = runtimeOptionsFactory.create();
            cleanClasspathList(runtimeOptions.getGlue());
            cleanClasspathList(runtimeOptions.getFeaturePaths());
        } else if (cukespaceConfig.containsKey(CucumberConfiguration.OPTIONS)) { // arquillian setting
            runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm"), asList((cukespaceConfig.getProperty(CucumberConfiguration.OPTIONS, "--strict") + " --strict").split(" ")));
        } else { // default
            runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm"), asList("--strict", "-f", "pretty", areColorsNotAvailable(cukespaceConfig)));
        }

        final boolean reported = Boolean.parseBoolean(cukespaceConfig.getProperty(CucumberConfiguration.REPORTABLE, "false"));
        final StringBuilder reportBuilder = new StringBuilder();
        if (reported) {
            runtimeOptions.addFormatter(new JSONFormatter(reportBuilder));
        }

        final Collection<Class<?>> glues = new LinkedList<Class<?>>();
        final InputStream gluesIs = tccl.getResourceAsStream(ClientServerFiles.GLUES_LIST);
        if (gluesIs != null) {
            final BufferedReader reader = new BufferedReader(new InputStreamReader(gluesIs));
            String line;

            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.isEmpty()) {
                    continue;
                }

                glues.add(tccl.loadClass(line));
            }
        } else { // client side
            glues.addAll(Glues.findGlues(clazz));
        }

        final cucumber.runtime.Runtime runtime = new cucumber.runtime.Runtime(null, tccl, Arrays.asList(new ArquillianBackend(glues, clazz, testInstance)), runtimeOptions) {
            @Override
            public void runStep(final String featurePath, final Step step, final Reporter reporter, final I18n i18n) {
                super.runStep(featurePath, step, new Reporter() {
                    @Override
                    public void match(final Match match) { // lazy to get the method and instance
                        if (StepDefinitionMatch.class.isInstance(match)) {
                            EventHelper.matched(StepDefinitionMatch.class.cast(match));
                            EventHelper.fire(new BeforeStep(featurePath, step));
                        }
                        reporter.match(match);
                    }

                    @Override
                    public void before(final Match match, final Result result) {
                        reporter.before(match, result);
                    }

                    @Override
                    public void result(final Result result) {
                        reporter.result(result);
                    }

                    @Override
                    public void after(final Match match, final Result result) {
                        reporter.after(match, result);
                    }

                    @Override
                    public void embedding(final String mimeType, final byte[] data) {
                        reporter.embedding(mimeType, data);
                    }

                    @Override
                    public void write(final String text) {
                        reporter.write(text);
                    }
                }, i18n);
                EventHelper.fire(new AfterStep(featurePath, step));
            }

            @Override
            public void runBeforeHooks(final Reporter reporter, final Set<Tag> tags) {
                EventHelper.fire(new BeforeBeforeHooks());
                super.runBeforeHooks(reporter, tags);
                EventHelper.fire(new AfterBeforeHooks());
            }

            @Override
            public void runAfterHooks(final Reporter reporter, final Set<Tag> tags) {
                EventHelper.fire(new BeforeAfterHooks());
                super.runAfterHooks(reporter, tags);
                EventHelper.fire(new AfterAfterHooks());
            }
        };

        final Formatter formatter = runtimeOptions.formatter(tccl);
        final JUnitReporter jUnitReporter = new JUnitReporter(runtimeOptions.reporter(tccl), formatter, runtimeOptions.isStrict());
        for (final CucumberFeature feature : cucumberFeatures) {
            LOGGER.info("Running " + feature.getPath());
            new FeatureRunner(feature, runtime, jUnitReporter).run(runNotifier);
        }
View Full Code Here

TOP

Related Classes of cucumber.runtime.RuntimeOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.