Exemplo 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);
  }
Exemplo 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);
  }
Exemplo n.º 3
0
  @Test
  public void
      test_givenTwoTestCasesInTsvFile_oneIsEmpty_andSecondIsJustVariableName_withEmptyExecute()
          throws Exception {
    // prepare
    final RobotRuntimeEnvironment runtime = mock(RobotRuntimeEnvironment.class);
    when(runtime.getVersion()).thenReturn("2.9");
    final RobotProjectHolder projectHolder = spy(RobotProjectHolder.class);
    when(projectHolder.getRobotRuntime()).thenReturn(runtime);

    final RobotParser parser =
        spy(RobotParser.create(projectHolder, RobotParserConfig.allImportsLazy()));

    //// prepare paths
    final File startFile =
        new File(this.getClass().getResource("parser/bugs/tsv_positionCheck.tsv").toURI());

    // execute
    final List<RobotFileOutput> output = parser.parse(startFile);

    // verify
    assertThat(output).hasSize(1);
    final RobotFileOutput file = output.get(0);
    final RobotFile robotModel = file.getFileModel();
    assertThatTestCaseTableIsIncluded(robotModel);
    final TestCaseTable testCaseTable = robotModel.getTestCaseTable();
    final List<TestCase> testCases = testCaseTable.getTestCases();
    assertThat(testCases).hasSize(2);
    final TestCase testCaseT3 = testCases.get(0);

    //// verify test case T3
    final RobotToken testCaseT3Name = testCaseT3.getName();
    assertThat(testCaseT3Name.getText()).isEqualTo("T3");
    assertThat(testCaseT3Name.getRaw()).isEqualTo("T3");
    final FilePosition tcT3Pos = testCaseT3Name.getFilePosition();
    assertThat(tcT3Pos.isSamePlace(new FilePosition(2, 0, 20))).as("got %s", tcT3Pos).isTrue();
    assertThat(testCaseT3.getExecutionContext()).isEmpty();

    //// verify test case ${x}
    final TestCase testCaseSpacesX = testCases.get(1);
    assertThat(testCaseSpacesX.getName().getText()).isEqualTo("${x}");
    assertThat(testCaseSpacesX.getName().getRaw()).isEqualTo("${x}");
    final FilePosition tcXPos = testCaseSpacesX.getName().getFilePosition();
    assertThat(tcXPos.isSamePlace(new FilePosition(3, 4, 28))).as("got %s", tcXPos).isTrue();
    final List<RobotExecutableRow<TestCase>> xTestExecutionList =
        testCaseSpacesX.getExecutionContext();
    assertThat(xTestExecutionList).hasSize(1);
    final IExecutableRowDescriptor<TestCase> xTestFirstLineDescription =
        xTestExecutionList.get(0).buildLineDescription();

    final RobotAction action = xTestFirstLineDescription.getAction();
    final RobotToken emptyAction = action.getToken();
    assertThat(emptyAction.getText()).isEmpty();
    assertThat(emptyAction.getRaw()).isEmpty();
    final FilePosition emptyActionPosition = emptyAction.getFilePosition();
    assertThat(emptyActionPosition.isSamePlace(new FilePosition(4, 5, 43)))
        .as("got %s", emptyActionPosition)
        .isTrue();
  }
  @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);
  }
Exemplo n.º 5
0
 private void assertThatTestCaseTableIsIncluded(final RobotFile fileModel) {
   assertThat(fileModel.getSettingTable().isPresent()).isFalse();
   assertThat(fileModel.getVariableTable().isPresent()).isFalse();
   assertThat(fileModel.getTestCaseTable().isPresent()).isTrue();
   assertThat(fileModel.getKeywordTable().isPresent()).isFalse();
 }