Esempio n. 1
0
  private void test_tagsDec_andComment(final String fileNameWithoutExt, final String userTestName)
      throws Exception {
    // prepare
    final String filePath = PRETTY_NEW_DIR_LOCATION + fileNameWithoutExt + "." + getExtension();
    final RobotFile modelFile = NewRobotFileTestHelper.getModelFileToModify("2.9");

    // test data prepare
    modelFile.includeTestCaseTableSection();
    TestCaseTable testCaseTable = modelFile.getTestCaseTable();

    RobotToken testName = new RobotToken();
    testName.setText(userTestName);
    TestCase test = new TestCase(testName);
    testCaseTable.addTest(test);
    TestCaseTags testTags = test.newTags();

    RobotToken cmTok1 = new RobotToken();
    cmTok1.setText("cm1");
    RobotToken cmTok2 = new RobotToken();
    cmTok2.setText("cm2");
    RobotToken cmTok3 = new RobotToken();
    cmTok3.setText("cm3");

    testTags.addCommentPart(cmTok1);
    testTags.addCommentPart(cmTok2);
    testTags.addCommentPart(cmTok3);

    // verify
    NewRobotFileTestHelper.assertNewModelTheSameAsInFile(filePath, modelFile);
  }
Esempio n. 2
0
  private void test_tags_withTagsAnd3Tags(
      final String fileNameWithoutExt, final String userTestName) throws Exception {
    // prepare
    final String filePath = PRETTY_NEW_DIR_LOCATION + fileNameWithoutExt + "." + getExtension();
    final RobotFile modelFile = NewRobotFileTestHelper.getModelFileToModify("2.9");

    // test data prepare
    modelFile.includeTestCaseTableSection();
    TestCaseTable testCaseTable = modelFile.getTestCaseTable();

    RobotToken testName = new RobotToken();
    testName.setText(userTestName);
    TestCase test = new TestCase(testName);
    testCaseTable.addTest(test);
    TestCaseTags testTags = test.newTags();

    RobotToken tagOne = new RobotToken();
    tagOne.setText("tag1");
    RobotToken tagTwo = new RobotToken();
    tagTwo.setText("tag2");
    RobotToken tagThree = new RobotToken();
    tagThree.setText("tag3");
    testTags.addTag(tagOne);
    testTags.addTag(tagTwo);
    testTags.addTag(tagThree);

    // verify
    NewRobotFileTestHelper.assertNewModelTheSameAsInFile(filePath, modelFile);
  }
  @Override
  public void map(
      final RobotLine currentLine,
      final RobotToken rt,
      final ParsingState currentState,
      final RobotFile fileModel) {
    List<TestCase> testCases = fileModel.getTestCaseTable().getTestCases();
    TestCase testCase = testCases.get(testCases.size() - 1);

    List<TestCaseTags> tags = testCase.getTags();
    TestCaseTags testCaseTags = tags.get(tags.size() - 1);
    testCaseTags.addCommentPart(rt);
  }
Esempio n. 4
0
 private void reportUnknownVariablesInTagsSetting(
     final TestCase testCase, final Set<String> variables) {
   final List<TestCaseTags> tags = testCase.getTags();
   for (final TestCaseTags testCaseTags : tags) {
     final List<RobotToken> tagsTokens = testCaseTags.getTags();
     for (final RobotToken tagToken : tagsTokens) {
       final List<VariableDeclaration> variablesDeclarationsInTag =
           new VariableExtractor()
               .extract(tagToken, validationContext.getFile().getName())
               .getCorrectVariables();
       if (!variablesDeclarationsInTag.isEmpty()) {
         reportUnknownVariablesInSettingWithoutExeRows(
             validationContext, reporter, variablesDeclarationsInTag, variables);
       }
     }
   }
 }