use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioWithBackground.
@Test
public void testScenarioWithBackground() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Background:\n" + " When background\n" + " Then background\n" + " Scenario: scenario\n" + " When step\n" + " Then step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("background", result("undefined"));
stepsToResult.put("step", result("undefined"));
long stepDuration = milliSeconds(0);
String actual = runFeatureWithTestNGFormatter(feature, stepsToResult, stepDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"1\" passed=\"0\" failed=\"0\" skipped=\"1\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"SKIP\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\"/>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioWithFailedSteps.
@Test
public void testScenarioWithFailedSteps() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Scenario: scenario\n" + " When step1\n" + " Then step2\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("step1", result("failed", new TestNGException("message", "stacktrace")));
stepsToResult.put("step2", result("skipped"));
long stepDuration = milliSeconds(0);
String actual = runFeatureWithTestNGFormatter(feature, stepsToResult, stepDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"1\" passed=\"0\" failed=\"1\" skipped=\"0\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"FAIL\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\">" + " <exception class=\"cucumber.runtime.formatter.TestNGFormatterTest$TestNGException\">" + " <message><![CDATA[When step1..................................................................failed\n" + "Then step2..................................................................skipped\n" + "]]></message>" + " <full-stacktrace><![CDATA[stacktrace]]></full-stacktrace>" + " </exception>" + " </test-method>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioWithPendingSteps.
@Test
public final void testScenarioWithPendingSteps() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Scenario: scenario\n" + " When step1\n" + " Then step2\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("step1", result("pending"));
stepsToResult.put("step2", result("skipped"));
long stepDuration = milliSeconds(0);
String actual = runFeatureWithTestNGFormatter(feature, stepsToResult, stepDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"1\" passed=\"0\" failed=\"0\" skipped=\"1\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"SKIP\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\"/>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioWithFailedAfterHook.
@Test
public void testScenarioWithFailedAfterHook() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Scenario: scenario\n" + " When step\n" + " Then step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("step", result("passed"));
List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>();
hooks.add(TestHelper.hookEntry("after", result("failed", new TestNGException("message", "stacktrace"))));
long stepHookDuration = milliSeconds(0);
String actual = runFeatureWithTestNGFormatter(feature, stepsToResult, hooks, stepHookDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"1\" passed=\"0\" failed=\"1\" skipped=\"0\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"FAIL\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\">" + " <exception class=\"cucumber.runtime.formatter.TestNGFormatterTest$TestNGException\">" + " <message><![CDATA[When step...................................................................passed\n" + "Then step...................................................................passed\n" + "]]></message>" + " <full-stacktrace><![CDATA[stacktrace]]></full-stacktrace>" + " </exception>" + " </test-method>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioWithUndefinedSteps.
@Test
public final void testScenarioWithUndefinedSteps() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Scenario: scenario\n" + " When step\n" + " Then step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("step", result("undefined"));
long stepDuration = milliSeconds(0);
String actual = runFeatureWithTestNGFormatter(feature, stepsToResult, stepDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"1\" passed=\"0\" failed=\"0\" skipped=\"1\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"SKIP\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\"/>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
Aggregations