public String getStepName(Step step) { return step.getKeyword() + step.getName(); }
private void addStepAndResultListing( StringBuilder sb ) { for ( int i = 0; i < steps.size(); i++ ) { int length = sb.length(); String resultStatus = "not executed"; if ( i < results.size() ) { resultStatus = results.get( i ).getStatus(); } sb.append( steps.get( i ).getKeyword() ); sb.append( steps.get( i ).getName() ); do { sb.append( "." ); } while ( sb.length() - length < 76 ); sb.append( resultStatus ); sb.append( "\n" ); } }
public StackTraceElement getStackTraceElement(String path) { return new StackTraceElement("✽", getKeyword() + getName(), path, getLine()); } }
@Override protected Description describeChild(Step step) { Description description = stepDescriptions.get(step); if (description == null) { description = Description.createTestDescription(getName(), step.getKeyword() + step.getName(), step); stepDescriptions.put(step, description); } return description; }
@Override protected Description describeChild(Step step) { Description description = stepDescriptions.get(step); if (description == null) { description = Description.createTestDescription(getName(), step.getKeyword() + step.getName(), step); stepDescriptions.put(step, description); } return description; }
public void step(Step step) { out.append(step.getKeyword()+step.getName()).append("\n"); writeRows(step.getRows()); }
private Step convertStep(gherkin.formatter.model.Step cucumberStep) { return new Step(cucumberStep.getKeyword(), cucumberStep.getName()); } }
public void step(Step step) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "Step: " + step.getKeyword() + " " + step.getName()); LOG.log(Level.FINE, " " + step.getRows()); // logger.fine(" " + step.getStackTraceElement()); } if (currentStep != null) { String error = "Step: {" + step.getKeyword() + "} name: {" + step.getName() + "} received before previous step: {" + step.getKeyword() + "} name: {" + step.getName() + "} handled! Maybe caused by broken JSON, see #JENKINS-21835"; listener.error(error); LOG.log(Level.SEVERE, error); if (!ignoreBadSteps) { throw new CucumberModelException(error); } } currentStep = step; }
private String getName( Step step ) { return escape( step.getKeyword() + " " + step.getName() ); }
private String getGherkinStep(Description description) { return ((Step) Fields.getValue(description, "fUniqueId")).getKeyword() + ((Step) Fields.getValue(description, "fUniqueId")).getName(); } }
public void step(Step step) { String keyword = step.getKeyword().trim().toLowerCase(); if ("given".equals(keyword)) { currentScenario.getGivens().put(step.getName(), 0.0); lastModifiedStepMap = currentScenario.getGivens(); } if ("when".equals(keyword)) { currentScenario.getWhens().put(step.getName(), 0.0); lastModifiedStepMap = currentScenario.getWhens(); } if ("then".equals(keyword)) { currentScenario.getThens().put(step.getName(), 0.0); lastModifiedStepMap = currentScenario.getThens(); } if ("and".equals(keyword)) { lastModifiedStepMap.put(step.getName(), 0.0); } }
@Override public void match( Match match ) { super.match( match ); if ( match instanceof StepDefinitionMatch ) { countStep(); Field stepField = ReflectionUtils.findField( StepDefinitionMatch.class, "step" ); stepField.setAccessible( true ); StepDefinitionMatch stepDefinitionMatch = (StepDefinitionMatch) match; try { Step step = (Step) stepField.get( stepDefinitionMatch ); MDC.put( "prefix", PREFIX_STEP ); LOG.info( "{}{} [line: {}]", step.getKeyword(), step.getName(), step.getLine() ); MDC.put( "prefix", PREFIX_CUSTOM ); } catch ( Exception e ) { } } }
@Override public void match(final Match match) { final StepUtils stepUtils = new StepUtils(currentFeature, currentScenario); if (match instanceof StepDefinitionMatch) { isNullMatch = false; final Step step = stepUtils.extractStep((StepDefinitionMatch) match); synchronized (gherkinSteps) { while (gherkinSteps.peek() != null && !stepUtils.isEqualSteps(step, gherkinSteps.peek())) { stepUtils.fireCanceledStep(gherkinSteps.remove()); } if (stepUtils.isEqualSteps(step, gherkinSteps.peek())) { gherkinSteps.remove(); } } final StepResult stepResult = new StepResult(); stepResult.setName(String.format("%s %s", step.getKeyword(), getStepName(step))) .setStart(System.currentTimeMillis()); final String scenarioUuid = scenarioUuids.get(currentScenario); lifecycle.startStep(scenarioUuid, stepUtils.getStepUuid(step), stepResult); createDataTableAttachment(step.getRows()); } }
private Step loadAndReplaceSteps(Step step, String filePathFromComment, Resource sourceResource) { DataReader dataReader; try { InputStream inputStream = sourceResource.getInputStream(); dataReader = DataReaderFactory.create(sourceResource.getFilename()); DataDTO data = dataReader.readTable(inputStream); List<DataTableRow> rows = Lists.newArrayList(); for (Integer lineNum : data.getValues().keySet()) { List<String> cells = Lists.newArrayList(data.getValues().get(lineNum)); String valueComment = String.format("# %s:%d", filePathFromComment, lineNum + 1); Comment comment = new Comment(valueComment, lineNum); List<Comment> comments = Lists.newArrayList(comment); int newLineNum = step.getLine() + 2; if (isPreview) { newLineNum += lineOffset; } DataTableRow row = new DataTableRow(comments, cells, newLineNum + 1); rows.add(row); lineOffset += 2; } // re-calculate lineOffset lineOffset = lineOffset - step.getRows().size() - 1; step = new Step(step.getComments(), step.getKeyword(), step.getName(), step.getLine(), rows, step.getDocString()); } catch (InstantiationException | IllegalAccessException | IOException e) { throw Throwables.propagate(e); } return step; }
@Override public void step(Step step) { if (lineOffset != 0 && isPreview) { int newLine = step.getLine().intValue() + lineOffset.intValue(); featureLineOffset.put(step.getLine().intValue(), newLine); step = new Step(step.getComments(), step.getKeyword(), step.getName(), newLine, step.getRows(), step.getDocString()); } if (step.getRows() != null && step.getRows().get(0) != null && !step.getRows().get(0).getComments().isEmpty()) { String filePathFromComment = getExtractFilePathFromComment(step.getRows().get(0).getComments().get(0).getValue()); Resource sourceResource = getSourceResource(filePathFromComment); if (sourceResource != null) { step = loadAndReplaceSteps(step, filePathFromComment, sourceResource); } } super.step(step); prettyFormatter.step(step); }
public StepDTO(Step step) { this.comments = CommentDTO.fromGherkinComments(step.getComments()); this.keyword = step.getKeyword(); this.name = step.getName(); this.line = step.getLine(); if (step.getRows() != null) { this.rows = new ArrayList<DataTableRowDTO>(); for (DataTableRow gherkinRow : step.getRows()) { this.rows.add(new DataTableRowDTO(gherkinRow)); } } if (step.getDocString() != null) { this.docString = new DocStringDTO(step.getDocString()); } }
private void printStep(String status, List<Argument> arguments, String location) { Step step = steps.remove(0); Format textFormat = getFormat(status); Format argFormat = getArgFormat(status); printComments(step.getComments(), " "); StringBuilder buffer = new StringBuilder(" "); buffer.append(textFormat.text(step.getKeyword())); stepPrinter.writeStep(new NiceAppendable(buffer), textFormat, argFormat, step.getName(), arguments); buffer.append(indentedLocation(location)); out.println(buffer); if (step.getRows() != null) { table(step.getRows()); } else if (step.getDocString() != null) { docString(step.getDocString()); } }
public StepExec convertStep(Step step) { StepExec stepExec = new StepExec(step.getKeyword(), step.getName()); stepExec.declareComments(convertComments(step.getComments())); DocString docString = step.getDocString(); if (docString != null) { stepExec.declareDocString(docString.getValue()); } stepExec.declareTable(convertTable(step.getRows())); return stepExec; }
@Override public Description getDescription() { if (description == null) { description = Description.createSuiteDescription(getName(), cucumberScenario.getGherkinModel()); if (cucumberScenario.getCucumberBackground() != null) { for (Step backgroundStep : cucumberScenario.getCucumberBackground().getSteps()) { // We need to make a copy of that step, so we have a unique one per scenario Step copy = new Step( backgroundStep.getComments(), backgroundStep.getKeyword(), backgroundStep.getName(), backgroundStep.getLine(), backgroundStep.getRows(), backgroundStep.getDocString() ); description.addChild(describeChild(copy)); runnerSteps.add(copy); } } for (Step step : getChildren()) { description.addChild(describeChild(step)); runnerSteps.add(step); } } return description; }
@Override public Description getDescription() { if (description == null) { description = Description.createSuiteDescription(getName(), cucumberScenario.getGherkinModel()); if (cucumberScenario.getCucumberBackground() != null) { for (Step backgroundStep : cucumberScenario.getCucumberBackground().getSteps()) { // We need to make a copy of that step, so we have a unique one per scenario Step copy = new Step( backgroundStep.getComments(), backgroundStep.getKeyword(), backgroundStep.getName(), backgroundStep.getLine(), backgroundStep.getRows(), backgroundStep.getDocString() ); description.addChild(describeChild(copy)); runnerSteps.add(copy); } } for (Step step : getChildren()) { description.addChild(describeChild(step)); runnerSteps.add(step); } } return description; }