SyntaxAwareStepValidator implements StepValidator { @Override public void validateSubstep(final ParentStep substep, final SyntaxErrorReporter syntaxErrorReporter) { final List<Step> steps = substep.getSteps(); if (steps != null) { for (final Step step : steps) { validate(step, new File(substep.getSubStepFileUri()), syntaxErrorReporter); } } } SyntaxAwareStepValidator(final Syntax syntax); @Override void validateFeatureFile(final FeatureFile featureFile, final SyntaxErrorReporter syntaxErrorReporter); @Override void validateSubstep(final ParentStep substep, final SyntaxErrorReporter syntaxErrorReporter);  }
@Test public void validatorReportsMissingSubstepsInDefinition() { File substepsFile = createSubstepsFile("error.substeps").getAbsoluteFile(); final PatternMap<ParentStep> substeps = substepsFileParser.loadSubSteps(substepsFile); final StepValidator stepValidator = createStepValidatorWithSubsteps("simple.substeps", mock); for (final ParentStep substep : substeps.values()) { stepValidator.validateSubstep(substep, mock); } verify(mock).reportFeatureError(eq(substepsFile), eq("SingleWord"), eq(5), eq(101), eq("Step \"SingleWord\" is not defined")); verify(mock).reportFeatureError(eq(substepsFile), eq("Test_Then something else has happened"), eq(6), anyInt(), any()); verify(mock).reportFeatureError(eq(substepsFile), eq("Test_Then something has happened"), eq(9), anyInt(), any()); }
@Test public void validatorReportsNoErrorsForSubstepsWithValidSteps() { final PatternMap<ParentStep> substeps = this.substepsFileParser .loadSubSteps(createSubstepsFile("allFeatures.substeps")); final StepValidator stepValidator = createStepValidatorWithSubsteps("simple.substeps", mock, MockStepImplementations.class); for (final ParentStep substep : substeps.values()) { stepValidator.validateSubstep(substep, mock); } verify(mock, never()).reportFeatureError(any(),any(),anyInt(),anyInt(),any()); verify(mock, never()).reportSubstepsError(any()); verify(mock, never()).reportStepImplError(any()); }