コード例 #1
0
 private boolean isItSingleScenario(Description description) {
   try {
     return description.getMethodName() != null;
   } catch (NoSuchMethodError e) { // junit 4.5
     return description.getDisplayName() != null;
   }
 }
コード例 #2
0
 private String createScenarioNameFromTestMethodName(
     Description description, Parameters parametersAnnotation) {
   try {
     return decamelise(description.getMethodName());
   } catch (NoSuchMethodError e) { // junit 4.5
     return decamelise(description.getDisplayName());
   }
 }
コード例 #3
0
  private ScenarioModel namedScenario(Description description) {
    Scenario scenarioAnnotation = description.getAnnotation(Scenario.class);
    Parameters parametersAnnotation = description.getAnnotation(Parameters.class);
    String name = null;

    if (scenarioHasDefinedName(scenarioAnnotation)) name = scenarioAnnotation.value();
    else name = createScenarioNameFromTestMethodName(description, parametersAnnotation);

    if (parametersAnnotation != null && !scenarioAnnotation.pending())
      name =
          name.substring(name.indexOf('(') + 1, name.indexOf(')'))
              + " ("
              + description
                  .getMethodName()
                  .substring(0, description.getMethodName().indexOf('(') - 1)
              + ")";

    return ScenarioManager.currentScenario().withName(name).withDescription(description);
  }