com.aventstack.extentreports.GherkinKeyword Java Examples
The following examples show how to use
com.aventstack.extentreports.GherkinKeyword.
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: RawEntityConverter.java From extentreports-java with Apache License 2.0 | 6 votes |
public void convertAndApply(File jsonFile) throws IOException { if (!jsonFile.exists()) { return; } extent.setReportUsesManualConfiguration(true); List<Test> tests = new JsonDeserializer(jsonFile).deserialize(); for (Test test : tests) { try { if (test.getBddType() == null) { createDomain(test, extent.createTest(test.getName(), test.getDescription())); } else { ExtentTest extentTest = extent.createTest(new GherkinKeyword(test.getBddType().toString()), test.getName(), test.getDescription()); createDomain(test, extentTest); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } }
Example #2
Source File: GherkinKeywordTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@Test public void testEnglishGherkinKeywords() throws ClassNotFoundException, UnsupportedEncodingException { ExtentReports extent = extent(); extent.setGherkinDialect("en"); ExtentTest feature = extent.createTest(new GherkinKeyword("Feature"), "Refund item VM"); ExtentTest scenario = feature.createNode(new GherkinKeyword("Scenario"), "Jeff returns a faulty microwave"); ExtentTest given = scenario.createNode(new GherkinKeyword("Given"), "Jeff has bought a microwave for $100").skip("skip"); ExtentTest and = scenario.createNode(new GherkinKeyword("And"), "he has a receipt").pass("pass"); ExtentTest when = scenario.createNode(new GherkinKeyword("When"), "he returns the microwave").pass("pass"); ExtentTest then = scenario.createNode(new GherkinKeyword("Then"), "Jeff should be refunded $100").skip("skip"); Assert.assertEquals(feature.getModel().getBddType(), Feature.class); Assert.assertEquals(scenario.getModel().getBddType(), Scenario.class); Assert.assertEquals(given.getModel().getBddType(), Given.class); Assert.assertEquals(and.getModel().getBddType(), And.class); Assert.assertEquals(when.getModel().getBddType(), When.class); Assert.assertEquals(then.getModel().getBddType(), Then.class); }
Example #3
Source File: GherkinKeywordTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@Test public void testGermanGherkinKeywords() throws ClassNotFoundException, UnsupportedEncodingException { ExtentReports extent = extent(); extent.setGherkinDialect("de"); ExtentTest feature = extent.createTest(new GherkinKeyword("Funktionalität"), "Refund item VM"); ExtentTest scenario = feature.createNode(new GherkinKeyword("Szenario"), "Jeff returns a faulty microwave"); ExtentTest given = scenario.createNode(new GherkinKeyword("Angenommen"), "Jeff has bought a microwave for $100").skip("skip"); ExtentTest and = scenario.createNode(new GherkinKeyword("Und"), "he has a receipt").pass("pass"); ExtentTest when = scenario.createNode(new GherkinKeyword("Wenn"), "he returns the microwave").pass("pass"); ExtentTest then = scenario.createNode(new GherkinKeyword("Dann"), "Jeff should be refunded $100").skip("skip"); Assert.assertEquals(feature.getModel().getBddType(), Feature.class); Assert.assertEquals(scenario.getModel().getBddType(), Scenario.class); Assert.assertEquals(given.getModel().getBddType(), Given.class); Assert.assertEquals(and.getModel().getBddType(), And.class); Assert.assertEquals(when.getModel().getBddType(), When.class); Assert.assertEquals(then.getModel().getBddType(), Then.class); }
Example #4
Source File: ExtentCucumberAdapter.java From extentreports-cucumber4-adapter with Apache License 2.0 | 6 votes |
private synchronized void createTestStep(PickleStepTestStep testStep) { String stepName = testStep.getStepText(); TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile.get(), testStep.getStepLine()); if (astNode != null) { Step step = (Step) astNode.node; try { String name = stepName == null || stepName.isEmpty() ? step.getText().replace("<", "<").replace(">", ">") : stepName; ExtentTest t = scenarioThreadLocal.get() .createNode(new GherkinKeyword(step.getKeyword().trim()), step.getKeyword() + name, testStep.getCodeLocation()); stepTestThreadLocal.set(t); } catch (ClassNotFoundException e) { e.printStackTrace(); } } if (!testStep.getStepArgument().isEmpty()) { Argument argument = testStep.getStepArgument().get(0); if (argument instanceof PickleString) { createDocStringMap((PickleString)argument); } else if (argument instanceof PickleTable) { List<PickleRow> rows = ((PickleTable) argument).getRows(); stepTestThreadLocal.get().pass(MarkupHelper.createTable(getPickleTable(rows)).getMarkup()); } } }
Example #5
Source File: RawEntityConverter.java From extentreports-java with Apache License 2.0 | 5 votes |
public void createDomain(Test test, ExtentTest extentTest) throws ClassNotFoundException { extentTest.getModel().setStartTime(test.getStartTime()); extentTest.getModel().setEndTime(test.getEndTime()); addMedia(test, extentTest); // create events for (Log log : test.getLogs()) { if (log.hasException() && log.hasMedia()) addMedia(log, extentTest, log.getException().getException()); else if (log.hasException()) extentTest.log(log.getStatus(), log.getException().getException()); else if (log.hasMedia()) addMedia(log, extentTest, null); else extentTest.log(log.getStatus(), log.getDetails()); } // assign attributes test.getAuthorSet().stream().map(x -> x.getName()).forEach(extentTest::assignAuthor); test.getCategorySet().stream().map(x -> x.getName()).forEach(extentTest::assignCategory); test.getDeviceSet().stream().map(x -> x.getName()).forEach(extentTest::assignDevice); // handle nodes for (Test node : test.getChildren()) { ExtentTest extentNode = null; if (node.getBddType() == null) extentNode = extentTest.createNode(node.getName(), node.getDescription()); else extentNode = extentTest.createNode(new GherkinKeyword(node.getBddType().toString()), node.getName(), node.getDescription()); addMedia(node, extentNode); createDomain(node, extentNode); } }
Example #6
Source File: TestServiceTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testWithBddTypeGherkinKeyword() throws ClassNotFoundException, UnsupportedEncodingException { GherkinDialectManager.setLanguage("en"); GherkinKeyword keyword = new GherkinKeyword("Scenario"); Test test = TestService.createTest(keyword.getClazz(), "Test", DESCRIPTION); Assert.assertEquals(test.getBddType(), keyword.getClazz()); }
Example #7
Source File: ExtentReportsBuilder.java From courgette-jvm with MIT License | 5 votes |
private ExtentTest createGherkinNode(ExtentTest parent, String keyword, String name, boolean appendKeyword) { try { String nodeName = appendKeyword ? (keyword + " " + name) : name; return parent.createNode(new GherkinKeyword(keyword), nodeName); } catch (ClassNotFoundException e) { throw new CourgetteException(e); } }