@Test public void teardownArgumentsProblemsAreReported() throws CoreException { final RobotSuiteFile file = new RobotSuiteFileCreator() .appendLine("*** Test Cases ***") .appendLine("case") .appendLine(" [Teardown] keyword") .build(); final Map<String, Collection<KeywordEntity>> keywords = new HashMap<>(); keywords.put( "keyword", newArrayList( newValidationKeywordEntity( KeywordScope.LOCAL, "file", "keyword", new Path("file"), "x"))); final FileValidationContext context = prepareContext(keywords); final TestCaseSettingsValidator validator = new TestCaseSettingsValidator(context, getTestCase(file), reporter); validator.validate(null); assertThat(reporter.getReportedProblems()) .containsOnly( new Problem( ArgumentProblem.INVALID_NUMBER_OF_PARAMETERS, new ProblemPosition(3, Range.closed(40, 47)))); }
@Ignore @Test public void duplicatedTeardownsAreReported() throws CoreException { final RobotSuiteFile file = new RobotSuiteFileCreator() .appendLine("*** Test Cases ***") .appendLine("case") .appendLine(" [Teardown] keyword") .appendLine(" [Teardown] keyword") .build(); final Map<String, Collection<KeywordEntity>> keywords = new HashMap<>(); keywords.put( "keyword", newArrayList( newValidationKeywordEntity(KeywordScope.LOCAL, "file", "keyword", new Path("file")))); final FileValidationContext context = prepareContext(keywords); final TestCaseSettingsValidator validator = new TestCaseSettingsValidator(context, getTestCase(file), reporter); validator.validate(null); assertThat(reporter.getReportedProblems()) .containsOnly( new Problem( TestCasesProblem.DUPLICATED_CASE_SETTING, new ProblemPosition(3, Range.closed(26, 36))), new Problem( TestCasesProblem.DUPLICATED_CASE_SETTING, new ProblemPosition(4, Range.closed(52, 62)))); }
@Ignore @Test public void duplicatedTimeoutsAreReported() throws CoreException { final RobotSuiteFile file = new RobotSuiteFileCreator() .appendLine("*** Test Cases ***") .appendLine("case") .appendLine(" [Timeout] 1") .appendLine(" [Timeout] 2") .build(); final FileValidationContext context = prepareContext(); final TestCaseSettingsValidator validator = new TestCaseSettingsValidator(context, getTestCase(file), reporter); validator.validate(null); assertThat(reporter.getReportedProblems()) .containsOnly( new Problem( TestCasesProblem.DUPLICATED_CASE_SETTING, new ProblemPosition(3, Range.closed(26, 35))), new Problem( TestCasesProblem.DUPLICATED_CASE_SETTING, new ProblemPosition(4, Range.closed(43, 52)))); }
@Test public void nothingIsReported_whenThereIsATagDefined() throws CoreException { final RobotSuiteFile file = new RobotSuiteFileCreator() .appendLine("*** Test Cases ***") .appendLine("case") .appendLine(" [Tags] tag") .build(); final FileValidationContext context = prepareContext(); final TestCaseSettingsValidator validator = new TestCaseSettingsValidator(context, getTestCase(file), reporter); validator.validate(null); assertThat(reporter.getReportedProblems()).isEmpty(); }
@Test public void emptyTagsSettingIsReported() throws CoreException { final RobotSuiteFile file = new RobotSuiteFileCreator() .appendLine("*** Test Cases ***") .appendLine("case") .appendLine(" [Tags]") .build(); final FileValidationContext context = prepareContext(); final TestCaseSettingsValidator validator = new TestCaseSettingsValidator(context, getTestCase(file), reporter); validator.validate(null); assertThat(reporter.getReportedProblems()) .containsOnly( new Problem( TestCasesProblem.EMPTY_CASE_SETTING, new ProblemPosition(3, Range.closed(26, 32)))); }
@Test public void nothingIsReported_whenThereIsATeardownDefined() throws CoreException { final RobotSuiteFile file = new RobotSuiteFileCreator() .appendLine("*** Test Cases ***") .appendLine("case") .appendLine(" [Teardown] keyword") .build(); final Map<String, Collection<KeywordEntity>> keywords = new HashMap<>(); keywords.put( "keyword", newArrayList( newValidationKeywordEntity(KeywordScope.LOCAL, "file", "keyword", new Path("file")))); final FileValidationContext context = prepareContext(keywords); final TestCaseSettingsValidator validator = new TestCaseSettingsValidator(context, getTestCase(file), reporter); validator.validate(null); assertThat(reporter.getReportedProblems()).isEmpty(); }