io.cucumber.plugin.event.TestSourceRead Java Examples

The following examples show how to use io.cucumber.plugin.event.TestSourceRead. 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: CucumberRunner.java    From cucumber-performance with MIT License 5 votes vote down vote up
private void configListeners() {
	// Pre Cucumber 4.0.0
	// trying to remove pretty but doesn't seem possible
	// you can do getPlugins() before creating the runtime to disable all plugins
	// however
	/*
	 * for (int i = 0; i <runtimeOptions.getPlugins().size();i++) {
	 * if(runtimeOptions.getPlugins().get(i).getClass().isInstance(new
	 * PluginFactory().create("pretty"))) { runtimeOptions.getPlugins().remove(i);
	 * System.out.println(""+runtimeOptions.getPlugins().get(i).getClass()); } }
	 */
	// reporter.setEventPublisher(eventBus);

	// Post Cucumber 4.0.0
	// Enable plugins
	// StepDefinitionReporter stepDefinitionReporter =
	// plugins.stepDefinitionReporter();
	// runnerSupplier.get().reportStepDefinitions(stepDefinitionReporter);

	for (Feature feature : this.options.getFeatures()) {
		 eventBus.send(new TestSourceRead(eventBus.getInstant(), feature.getUri(), feature.getSource()));
	}

	// Enable plugins
	// StepDefinitionReporter stepDefinitionReporter =
	// plugins.stepDefinitionReporter();
	// runnerSupplier.get().reportStepDefinitions(stepDefinitionReporter);

	resultListener = new GroupResultListener();
	resultListener.setEventPublisher(eventBus);
	resultListener.setGroupName(options.getGroupText());

	testCaseResultListener = new TestCaseResultListener();
	testCaseResultListener.setEventPublisher(eventBus);

	stepResultListener = new StepResultListener();
	stepResultListener.setEventPublisher(eventBus);
}
 
Example #2
Source File: JustTestLahRunner.java    From justtestlah with Apache License 2.0 5 votes vote down vote up
@Override
public void evaluate() throws Throwable {
  if (multiThreadingAssumed) {
    plugins.setSerialEventBusOnEventListenerPlugins(bus);
  } else {
    plugins.setEventBusOnEventListenerPlugins(bus);
  }

  bus.send(new TestRunStarted(bus.getInstant()));
  for (Feature feature : features) {
    bus.send(new TestSourceRead(bus.getInstant(), feature.getUri(), feature.getSource()));
  }
  runFeatures.evaluate();
  bus.send(new TestRunFinished(bus.getInstant()));
}
 
Example #3
Source File: TestSourcesModelProxy.java    From allure-java with Apache License 2.0 5 votes vote down vote up
private String getKeywordFromSourceInternal(final URI uri, final int stepLine) {
    final Feature feature = getFeature(uri);
    if (feature != null) {
        final TestSourceRead event = this.getTestSourceReadEvent(uri);
        final String trimmedSourceLine = event.getSource().split("\n")[stepLine - 1].trim();
        final GherkinDialect dialect = new GherkinDialectProvider(feature.getLanguage()).getDefaultDialect();
        for (String keyword : dialect.getStepKeywords()) {
            if (trimmedSourceLine.startsWith(keyword)) {
                return keyword;
            }
        }
    }
    return "";
}
 
Example #4
Source File: PerfPlan.java    From cucumber-performance with MIT License 4 votes vote down vote up
public void sendTestSourceRead(EventBus bus) {
    bus.send(new TestSourceRead(bus.getInstant(), uri, saladSource));
}
 
Example #5
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public void addTestSourceReadEvent(final URI path, final TestSourceRead event) {
    pathToReadEventMap.put(path, event);
}
 
Example #6
Source File: TestSourcesModelProxy.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public void addTestSourceReadEvent(final URI path, final TestSourceRead event) {
    this.pathToReadEventMap.put(path, event);
    testSources.addTestSourceReadEvent(path, event);
}
 
Example #7
Source File: TestSourcesModelProxy.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private TestSourceRead getTestSourceReadEvent(final URI uri) {
    if (this.pathToReadEventMap.containsKey(uri)) {
        return pathToReadEventMap.get(uri);
    }
    return null;
}