use of gherkin.formatter.model.Feature in project cucumber-jvm by cucumber.
the class JUnitReporterTest method forward_calls_to_formatter_interface_methods.
@Test
public void forward_calls_to_formatter_interface_methods() throws Exception {
String uri = "uri";
Feature feature = mock(Feature.class);
Background background = mock(Background.class);
ScenarioOutline scenarioOutline = mock(ScenarioOutline.class);
Examples examples = mock(Examples.class);
Scenario scenario = mock(Scenario.class);
Step step = mock(Step.class);
Formatter formatter = mock(Formatter.class);
jUnitReporter = new JUnitReporter(mock(Reporter.class), formatter, false, new JUnitOptions(Collections.<String>emptyList()));
jUnitReporter.uri(uri);
jUnitReporter.feature(feature);
jUnitReporter.scenarioOutline(scenarioOutline);
jUnitReporter.examples(examples);
jUnitReporter.startOfScenarioLifeCycle(scenario);
jUnitReporter.background(background);
jUnitReporter.scenario(scenario);
jUnitReporter.step(step);
jUnitReporter.endOfScenarioLifeCycle(scenario);
jUnitReporter.eof();
jUnitReporter.done();
jUnitReporter.close();
verify(formatter).uri(uri);
verify(formatter).feature(feature);
verify(formatter).scenarioOutline(scenarioOutline);
verify(formatter).examples(examples);
verify(formatter).startOfScenarioLifeCycle(scenario);
;
verify(formatter).background(background);
verify(formatter).scenario(scenario);
verify(formatter).step(step);
verify(formatter).endOfScenarioLifeCycle(scenario);
verify(formatter).eof();
verify(formatter).done();
verify(formatter).close();
}
use of gherkin.formatter.model.Feature in project cucumber-jvm by cucumber.
the class CucumberExamplesTest method should_create_example_scenarios.
@Test
public void should_create_example_scenarios() {
CucumberFeature cucumberFeature = new CucumberFeature(new Feature(COMMENTS, FEATURE_TAGS, "Feature", "", "", 2, "fid"), "f.feature");
ScenarioOutline so = new ScenarioOutline(COMMENTS, SO_TAGS, "Scenario Outline", "", "", 4, "");
CucumberScenarioOutline cso = new CucumberScenarioOutline(cucumberFeature, null, so);
cso.step(new Step(COMMENTS, "Given ", "I have 5 <what> in my <where>", 5, null, null));
Examples examples = new Examples(COMMENTS, E_TAGS, "Examples", "", "", 6, "", asList(new ExamplesTableRow(COMMENTS, asList("what", "where"), 7, ""), new ExamplesTableRow(COMMENTS, asList("cukes", "belly"), 8, ""), new ExamplesTableRow(COMMENTS, asList("apples", "basket"), 9, "")));
CucumberExamples cucumberExamples = new CucumberExamples(cso, examples);
List<CucumberScenario> exampleScenarios = cucumberExamples.createExampleScenarios();
assertEquals(2, exampleScenarios.size());
Set<Tag> expectedTags = new HashSet<Tag>();
expectedTags.addAll(FEATURE_TAGS);
expectedTags.addAll(SO_TAGS);
expectedTags.addAll(E_TAGS);
assertEquals(expectedTags, exampleScenarios.get(0).tagsAndInheritedTags());
CucumberScenario cucumberScenario = exampleScenarios.get(0);
Step step = cucumberScenario.getSteps().get(0);
assertEquals("I have 5 cukes in my belly", step.getName());
}
use of gherkin.formatter.model.Feature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method feature.
private Feature feature(String featureName) {
Feature feature = mock(Feature.class);
when(feature.getName()).thenReturn(featureName);
return feature;
}
use of gherkin.formatter.model.Feature in project cucumber-jvm by cucumber.
the class HookTest method after_hooks_execute_before_objects_are_disposed.
/**
* Test for <a href="https://github.com/cucumber/cucumber-jvm/issues/23">#23</a>.
* TODO: ensure this is no longer needed with the alternate approach taken in Runtime
* TODO: this test is rather brittle, since there's lots of mocking :(
*/
@Test
public void after_hooks_execute_before_objects_are_disposed() throws Throwable {
Backend backend = mock(Backend.class);
HookDefinition hook = mock(HookDefinition.class);
when(hook.matches(anyListOf(Tag.class))).thenReturn(true);
gherkin.formatter.model.Scenario gherkinScenario = mock(gherkin.formatter.model.Scenario.class);
CucumberFeature feature = mock(CucumberFeature.class);
Feature gherkinFeature = mock(Feature.class);
when(feature.getGherkinFeature()).thenReturn(gherkinFeature);
when(gherkinFeature.getTags()).thenReturn(new ArrayList<Tag>());
CucumberScenario scenario = new CucumberScenario(feature, null, gherkinScenario);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
RuntimeOptions runtimeOptions = new RuntimeOptions("");
Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, asList(backend), runtimeOptions);
runtime.getGlue().addAfterHook(hook);
scenario.run(mock(Formatter.class), mock(Reporter.class), runtime);
InOrder inOrder = inOrder(hook, backend);
inOrder.verify(hook).execute(Matchers.<Scenario>any());
inOrder.verify(backend).disposeWorld();
}
Aggregations