@Test
 public void star_keyword_becomes_given_when_no_previous_step() {
   Backend backend = new TestBackend();
   UndefinedStepsTracker tracker = new UndefinedStepsTracker();
   tracker.addUndefinedStep(new Step(null, "* ", "A", 1, null, null), ENGLISH);
   assertEquals("[Given ^A$]", tracker.getSnippets(asList(backend)).toString());
 }
 @Test
 public void snippets_are_generated_for_correct_locale() throws Exception {
   Backend backend = new TestBackend();
   UndefinedStepsTracker tracker = new UndefinedStepsTracker();
   tracker.addUndefinedStep(new Step(null, "Если ", "Б", 1, null, null), new I18n("ru"));
   assertEquals("[Если ^Б$]", 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 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 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());
 }
Exemple #6
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);
   }
 }
 @Test
 public void has_no_undefined_steps() {
   UndefinedStepsTracker undefinedStepsTracker = new UndefinedStepsTracker();
   assertFalse(undefinedStepsTracker.hasUndefinedSteps());
 }
 @Test
 public void has_undefined_steps() {
   UndefinedStepsTracker undefinedStepsTracker = new UndefinedStepsTracker();
   undefinedStepsTracker.addUndefinedStep(new Step(null, "Given ", "A", 1, null, null), ENGLISH);
   assertTrue(undefinedStepsTracker.hasUndefinedSteps());
 }