Java Code Examples for cucumber.runtime.model.CucumberFeature#sendTestSourceRead()

The following examples show how to use cucumber.runtime.model.CucumberFeature#sendTestSourceRead() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllureCucumber2JvmTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
private AllureResults runFeature(final String featureResource,
                                 final String... moreOptions) {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    final AllureLifecycle lifecycle = new AllureLifecycle(writer);
    final AllureCucumber2Jvm cucumber2Jvm = new AllureCucumber2Jvm(lifecycle);
    final ClassLoader classLoader = currentThread().getContextClassLoader();
    final ResourceLoader resourceLoader = new MultiLoader(classLoader);
    final ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
    final List<String> opts = new ArrayList<>(Arrays.asList(
            "--glue", "io.qameta.allure.cucumber2jvm.samples",
            "--plugin", "null"
    ));
    opts.addAll(Arrays.asList(moreOptions));
    final RuntimeOptions options = new RuntimeOptions(opts);
    final Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, options);

    options.addPlugin(cucumber2Jvm);

    final String gherkin = readResource(featureResource);
    Parser<GherkinDocument> parser = new Parser<>(new AstBuilder());
    TokenMatcher matcher = new TokenMatcher();
    GherkinDocument gherkinDocument = parser.parse(gherkin, matcher);
    CucumberFeature feature = new CucumberFeature(gherkinDocument, featureResource, gherkin);

    feature.sendTestSourceRead(runtime.getEventBus());
    runtime.runFeature(feature);
    return writer;
}
 
Example 2
Source File: AllureCucumber3JvmTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
private AllureResults runFeature(final String featureResource,
                                 final String... moreOptions) {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    final AllureLifecycle lifecycle = new AllureLifecycle(writer);
    final AllureCucumber3Jvm cucumber3Jvm = new AllureCucumber3Jvm(lifecycle);
    final ClassLoader classLoader = currentThread().getContextClassLoader();
    final ResourceLoader resourceLoader = new MultiLoader(classLoader);
    final ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
    final List<String> opts = new ArrayList<>(Arrays.asList(
            "--glue", "io.qameta.allure.cucumber3jvm.samples",
            "--plugin", "null"
    ));
    opts.addAll(Arrays.asList(moreOptions));
    final RuntimeOptions options = new RuntimeOptions(opts);
    final Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, options);

    options.addPlugin(cucumber3Jvm);
    options.noSummaryPrinter();

    final String gherkin = readResource(featureResource);
    Parser<GherkinDocument> parser = new Parser<>(new AstBuilder());
    TokenMatcher matcher = new TokenMatcher();
    GherkinDocument gherkinDocument = parser.parse(gherkin, matcher);
    CucumberFeature feature = new CucumberFeature(gherkinDocument, featureResource, gherkin);

    feature.sendTestSourceRead(runtime.getEventBus());
    runtime.runFeature(feature);
    return writer;
}
 
Example 3
Source File: CucumberRunner.java    From bdt with Apache License 2.0 5 votes vote down vote up
List<CucumberFeature> getFeatures() {
    plugins.setSerialEventBusOnEventListenerPlugins(bus);

    List<CucumberFeature> features = featureSupplier.get();
    bus.send(new TestRunStarted(bus.getTime(), bus.getTimeMillis()));
    for (CucumberFeature feature : features) {
        feature.sendTestSourceRead(bus);
    }
    return features;
}