Exemplo n.º 1
0
 @Override
 public Description getDescription() {
   if (description == null) {
     description = Description.createSuiteDescription(getName(), cucumberExamples.getExamples());
     for (Runner child : getChildren()) {
       description.addChild(describeChild(child));
     }
   }
   return description;
 }
  @Override
  public void onStart() {
    Looper.prepare();

    List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader);
    int numScenarios = 0;

    for (CucumberFeature feature : cucumberFeatures) {
      for (CucumberTagStatement statement : feature.getFeatureElements()) {
        if (statement instanceof CucumberScenario) {
          numScenarios++;
        } else if (statement instanceof CucumberScenarioOutline) {
          for (CucumberExamples examples :
              ((CucumberScenarioOutline) statement).getCucumberExamplesList()) {
            for (ExamplesTableRow row : examples.getExamples().getRows()) {
              numScenarios++;
            }
          }
          numScenarios--; // subtract table header
        }
      }
    }

    AndroidReporter reporter = new AndroidReporter(numScenarios);
    runtimeOptions.getFormatters().clear();
    runtimeOptions.getFormatters().add(reporter);

    for (CucumberFeature cucumberFeature : cucumberFeatures) {
      Formatter formatter = runtimeOptions.formatter(classLoader);
      cucumberFeature.run(formatter, reporter, runtime);
    }
    Formatter formatter = runtimeOptions.formatter(classLoader);

    formatter.done();
    printSummary();
    formatter.close();

    finish(Activity.RESULT_OK, new Bundle());
  }
Exemplo n.º 3
0
  protected ExamplesRunner(
      Runtime runtime, CucumberExamples cucumberExamples, JUnitReporter jUnitReporter)
      throws InitializationError {
    super(ExamplesRunner.class, new ArrayList<Runner>());
    this.cucumberExamples = cucumberExamples;

    List<CucumberScenario> exampleScenarios = cucumberExamples.createExampleScenarios();
    for (CucumberScenario scenario : exampleScenarios) {
      try {
        ExecutionUnitRunner exampleScenarioRunner =
            new ExecutionUnitRunner(runtime, scenario, jUnitReporter);
        getChildren().add(exampleScenarioRunner);
      } catch (InitializationError initializationError) {
        initializationError.printStackTrace();
      }
    }
  }
Exemplo n.º 4
0
 @Override
 protected String getName() {
   return cucumberExamples.getExamples().getKeyword()
       + ": "
       + cucumberExamples.getExamples().getName();
 }