use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_call_formatter_for_two_scenarios_with_background.
@Test
public void should_call_formatter_for_two_scenarios_with_background() throws Throwable {
CucumberFeature cucumberFeature = TestFeatureBuilder.feature("path/test.feature", "" + "Feature: feature name\n" + " Background: background\n" + " Given first step\n" + " Scenario: scenario_1 name\n" + " When second step\n" + " Then third step\n" + " Scenario: scenario_2 name\n" + " Then second step\n");
String formatterOutput = runFeatureWithFormatterSpy(cucumberFeature);
assertEquals("" + "uri\n" + "feature\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " step\n" + " match\n" + " result\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + "eof\n", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestFeatureBuilder method feature.
static CucumberFeature feature(final String path, final String source) throws IOException {
ArrayList<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
FeatureBuilder featureBuilder = new FeatureBuilder(cucumberFeatures);
featureBuilder.parse(new Resource() {
@Override
public String getPath() {
return path;
}
@Override
public String getAbsolutePath() {
throw new UnsupportedOperationException();
}
@Override
public InputStream getInputStream() {
try {
return new ByteArrayInputStream(source.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@Override
public String getClassName(String extension) {
throw new UnsupportedOperationException();
}
}, new ArrayList<Object>());
featureBuilder.close();
return cucumberFeatures.get(0);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestNGCucumberRunner method provideFeatures.
/**
* @return returns the cucumber features as a two dimensional array of
* {@link CucumberFeatureWrapper} objects.
*/
public Object[][] provideFeatures() {
try {
List<CucumberFeature> features = getFeatures();
List<Object[]> featuresList = new ArrayList<Object[]>(features.size());
for (CucumberFeature feature : features) {
featuresList.add(new Object[] { new CucumberFeatureWrapperImpl(feature) });
}
return featuresList.toArray(new Object[][] {});
} catch (CucumberException e) {
return new Object[][] { new Object[] { new CucumberExceptionWrapper(e) } };
}
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_scenario_outlines_with_multiple_examples.
@Test
public void should_format_scenario_outlines_with_multiple_examples() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario Outline: outline name\n" + " Given first step \"<arg>\"\n" + " When second step\n" + " Then third step\n\n" + " Examples: examples 1\n" + " | arg |\n" + " | a |\n" + " | b |\n\n" + " Examples: examples 2\n" + " | arg |\n" + " | c |\n" + " | d |\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("passed"));
stepsToResult.put("third step", result("passed"));
long stepDuration = milliSeconds(1);
String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"4\" time=\"0.012\">\n" + " <testcase classname=\"feature name\" name=\"outline name\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"a\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name 2\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"b\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name 3\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"c\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name 4\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"d\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestHelper method feature.
public static CucumberFeature feature(final String path, final String source) throws IOException {
ArrayList<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
FeatureBuilder featureBuilder = new FeatureBuilder(cucumberFeatures);
featureBuilder.parse(new Resource() {
@Override
public String getPath() {
return path;
}
@Override
public String getAbsolutePath() {
throw new UnsupportedOperationException();
}
@Override
public InputStream getInputStream() {
try {
return new ByteArrayInputStream(source.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@Override
public String getClassName(String extension) {
throw new UnsupportedOperationException();
}
}, new ArrayList<Object>());
return cucumberFeatures.get(0);
}
Aggregations