@Test
 public void converts_and_to_previous_step_keyword() {
   Backend backend = new TestBackend();
   UndefinedStepsTracker tracker = new UndefinedStepsTracker();
   tracker.storeStepKeyword(new Step(null, "When ", "A", 1, null, null), ENGLISH);
   tracker.storeStepKeyword(new Step(null, "And ", "B", 1, null, null), ENGLISH);
   tracker.addUndefinedStep(new Step(null, "But ", "C", 1, null, null), ENGLISH);
   assertEquals("[When ^C$]", tracker.getSnippets(asList(backend)).toString());
 }
 @Test
 public void doesnt_try_to_use_star_keyword() {
   Backend backend = new TestBackend();
   UndefinedStepsTracker tracker = new UndefinedStepsTracker();
   tracker.storeStepKeyword(new Step(null, "When ", "A", 1, null, null), ENGLISH);
   tracker.storeStepKeyword(new Step(null, "And ", "B", 1, null, null), ENGLISH);
   tracker.addUndefinedStep(new Step(null, "* ", "C", 1, null, null), ENGLISH);
   assertEquals("[When ^C$]", tracker.getSnippets(asList(backend)).toString());
 }
 @Test
 public void removes_duplicates() {
   Backend backend = new TestBackend();
   UndefinedStepsTracker tracker = new UndefinedStepsTracker();
   tracker.storeStepKeyword(new Step(null, "Given ", "A", 1, null, null), ENGLISH);
   tracker.addUndefinedStep(new Step(null, "Given ", "B", 1, null, null), ENGLISH);
   tracker.addUndefinedStep(new Step(null, "Given ", "B", 1, null, null), ENGLISH);
   assertEquals("[Given ^B$]", tracker.getSnippets(asList(backend)).toString());
 }
Exemplo n.º 4
0
 @Override
 public StepDefinitionMatch stepDefinitionMatch(String uri, Step step, I18n i18n) {
   List<StepDefinitionMatch> matches = stepDefinitionMatches(uri, step);
   try {
     if (matches.size() == 0) {
       tracker.addUndefinedStep(step, i18n);
       return null;
     }
     if (matches.size() == 1) {
       return matches.get(0);
     } else {
       throw new AmbiguousStepDefinitionsException(matches);
     }
   } finally {
     tracker.storeStepKeyword(step, i18n);
   }
 }