@Override
 public void result(Result result) {
   if (result.getError() != null) {
     // If the result contains an error, report a failure.
     testResult.putString(REPORT_KEY_STACK, result.getErrorMessage());
     resultCode = REPORT_VALUE_RESULT_FAILURE;
     testResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, result.getErrorMessage());
   } else if (result.getStatus().equals("undefined")) {
     // There was a missing step definition, report an error.
     List<String> snippets = runtime.getSnippets();
     String report =
         String.format(
             "Missing step-definition\n\n%s\nfor step '%s'",
             snippets.get(snippets.size() - 1), currentStep.getName());
     testResult.putString(REPORT_KEY_STACK, report);
     resultCode = REPORT_VALUE_RESULT_ERROR;
     testResult.putString(
         Instrumentation.REPORT_KEY_STREAMRESULT,
         String.format("Missing step-definition: %s", currentStep.getName()));
   }
 }
 public List<Argument> matchedArguments(Step step) {
   try {
     Object args = backend.invoke(iokeStepDefObject, "arguments_from", step.getName());
     if (args.equals(ioke.nil)) {
       return null;
     } else {
       return (List<Argument>) args;
     }
   } catch (ControlFlow controlFlow) {
     throw new RuntimeException("Failed to get step args", controlFlow);
   }
 }
  @Test
  public void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario()
      throws Exception {
    List<CucumberFeature> features =
        CucumberFeature.load(
            new ClasspathResourceLoader(this.getClass().getClassLoader()),
            asList("cucumber/junit/feature_with_same_steps_in_scenario.feature"),
            Collections.emptyList());

    ExecutionUnitRunner runner =
        new ExecutionUnitRunner(
            null, (CucumberScenario) features.get(0).getFeatureElements().get(0), null);

    // fish out the two occurrences of the same step and check whether we really got them
    Step stepOccurrence1 = runner.getChildren().get(0);
    Step stepOccurrence2 = runner.getChildren().get(2);
    assertEquals(stepOccurrence1.getName(), stepOccurrence2.getName());

    assertFalse(
        "Descriptions must not be equal.",
        runner.describeChild(stepOccurrence1).equals(runner.describeChild(stepOccurrence2)));
  }
 private CucumberException arityMismatch(int parameterCount) {
   List<Argument> arguments = createArgumentsForErrorMessage(step);
   return new CucumberException(
       String.format(
           "Arity mismatch: Step Definition '%s' with pattern [%s] is declared with %s parameters. However, the gherkin step has %s arguments %s. \nStep: %s%s",
           stepDefinition.getLocation(true),
           stepDefinition.getPattern(),
           parameterCount,
           arguments.size(),
           arguments,
           step.getKeyword(),
           step.getName()));
 }
  @Override
  public void result(Result result) {
    // addTestNgAttribute(RESULTS, result);
    String timing =
        result.getDuration() != null
            ? " : " + (Math.round(result.getDuration() / 1000000000f * 100f) / 100f) + "s"
            : "";
    Step step;
    if (steps.isEmpty()) {
      step = new Step(null, "MISMATCH BETWEEN STEPS AND RESULTS", "", 0, null, null);
    } else {
      step = steps.pop();
    }
    org.testng.Reporter.log(
        "<div class=\"result\">"
            + step.getKeyword()
            + " "
            + step.getName()
            + " ("
            + result.getStatus()
            + timing
            + ")</div>");

    if (Result.FAILED.equals(result)) {
      ITestResult tr = org.testng.Reporter.getCurrentTestResult();
      tr.setThrowable(result.getError());
      tr.setStatus(ITestResult.FAILURE);
      failureCount.incrementAndGet();
    } else if (Result.SKIPPED.equals(result)) {
      ITestResult tr = org.testng.Reporter.getCurrentTestResult();
      tr.setThrowable(result.getError());
      tr.setStatus(ITestResult.SKIP);
      skipCount.incrementAndGet();
    } else if (Result.UNDEFINED.equals(result)) {
      ITestResult tr = org.testng.Reporter.getCurrentTestResult();
      tr.setThrowable(result.getError());
      tr.setStatus(ITestResult.FAILURE);
      failureCount.incrementAndGet();
    } else {
      passCount.incrementAndGet();
    }
  }
 public List<Argument> matchedArguments(Step step) {
   return argumentMatcher.argumentsFrom(step.getName());
 }
 public String getStepName() {
   return step.getName();
 }