private static void writeBytesToURL(byte[] buf, URL url) throws CucumberException { OutputStream out = createReportFileOutputStream(url); try { out.write(buf); } catch (IOException e) { throw new CucumberException("Unable to write to report file item: ", e); } finally { closeQuietly(out); } }
private Map<String, Object> createRowMap(TableRow row) { Map<String, Object> rowMap = new HashMap<String, Object>(); rowMap.put("cells", createCellList(row)); return rowMap; }
private void handleStartOfFeature(TestCase testCase) { if (currentFeatureFile == null || !currentFeatureFile.equals(testCase.getUri())) { currentFeatureFile = testCase.getUri(); jsFunctionCall("uri", currentFeatureFile); jsFunctionCall("feature", createFeature(testCase)); } }
private void handleTestCaseStarted(TestCaseStarted event) { if (firstFeature) { jsOut.append("$(document).ready(function() {").append("var ") .append(JS_FORMATTER_VAR).append(" = new CucumberHTML.DOMFormatter($('.cucumber-report'));"); firstFeature = false; } handleStartOfFeature(event.testCase); handleScenarioOutline(event.testCase); currentTestCaseMap = createTestCase(event.testCase); if (testSources.hasBackground(currentFeatureFile, event.testCase.getLine())) { jsFunctionCall("background", createBackground(event.testCase)); } else { jsFunctionCall("scenario", currentTestCaseMap); currentTestCaseMap = null; } }
private void handleScenarioOutline(TestCase testCase) { TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testCase.getLine()); if (TestSourcesModel.isScenarioOutlineScenario(astNode)) { ScenarioOutline scenarioOutline = (ScenarioOutline)TestSourcesModel.getScenarioDefinition(astNode); if (currentScenarioOutline == null || !currentScenarioOutline.equals(scenarioOutline)) { currentScenarioOutline = scenarioOutline; jsFunctionCall("scenarioOutline", createScenarioOutline(currentScenarioOutline)); addOutlineStepsToReport(scenarioOutline); } Examples examples = (Examples)astNode.parent.node; if (currentExamples == null || !currentExamples.equals(examples)) { currentExamples = examples; jsFunctionCall("examples", createExamples(currentExamples)); } } else { currentScenarioOutline = null; currentExamples = null; } }
private void addOutlineStepsToReport(ScenarioOutline scenarioOutline) { for (Step step : scenarioOutline.getSteps()) { Map<String, Object> stepMap = new HashMap<String, Object>(); stepMap.put("name", step.getText()); stepMap.put("keyword", step.getKeyword()); if (step.getArgument() != null) { Node argument = step.getArgument(); if (argument instanceof DocString) { stepMap.put("doc_string", createDocStringMap((DocString)argument)); } else if (argument instanceof DataTable) { stepMap.put("rows", createDataTableList((DataTable)argument)); } } jsFunctionCall("step", stepMap); } }
private Map<String, Object> createTestStep(PickleStepTestStep testStep) { Map<String, Object> stepMap = new HashMap<String, Object>(); stepMap.put("name", testStep.getStepText()); if (!testStep.getStepArgument().isEmpty()) { Argument argument = testStep.getStepArgument().get(0); if (argument instanceof PickleString) { stepMap.put("doc_string", createDocStringMap((PickleString)argument)); } else if (argument instanceof PickleTable) { stepMap.put("rows", createDataTableList((PickleTable)argument)); } } TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testStep.getStepLine()); if (astNode != null) { Step step = (Step) astNode.node; stepMap.put("keyword", step.getKeyword()); } return stepMap; }
@SuppressWarnings("WeakerAccess") // Used by PluginFactory public HTMLFormatter(URL htmlReportDir) { this(htmlReportDir, createJsOut(htmlReportDir)); }
private void finishReport() { if (!firstFeature) { jsOut.append("});"); copyReportFiles(); } jsOut.close(); }
private static void writeStreamToURL(InputStream in, URL url) { OutputStream out = createReportFileOutputStream(url); byte[] buffer = new byte[16 * 1024]; try { int len = in.read(buffer); while (len != -1) { out.write(buffer, 0, len); len = in.read(buffer); } } catch (IOException e) { throw new CucumberException("Unable to write to report file item: ", e); } finally { closeQuietly(out); } }
private Map<String, Object> createRowMap(PickleRow row) { Map<String, Object> rowMap = new HashMap<String, Object>(); rowMap.put("cells", createCellList(row)); return rowMap; }