com.intellij.rt.execution.junit.FileComparisonFailure Java Examples

The following examples show how to use com.intellij.rt.execution.junit.FileComparisonFailure. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HaskellLexerTestBase.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
/**
 * Check the result against a plain text file. Creates file if missing.
 * Avoids the default sandboxing in IntelliJ.
 */
public static void doCheckResult(String fullPath, String targetDataName, String text) throws IOException {
    text = text.trim();
    String expectedFileName = fullPath + File.separator + targetDataName;
    if (OVERWRITE_TESTDATA) {
        VfsTestUtil.overwriteTestData(expectedFileName, text);
        System.out.println("File " + expectedFileName + " created.");
    }
    try {
        String expectedText = doLoadFile(fullPath, targetDataName);
        if (!Comparing.equal(expectedText, text)) {
            throw new FileComparisonFailure(targetDataName, expectedText, text, expectedFileName);
        }
    } catch(FileNotFoundException e){
        VfsTestUtil.overwriteTestData(expectedFileName, text);
        fail("No output text found. File " + expectedFileName + " created.");
    }
}
 
Example #2
Source File: MavenTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected static void assertUnorderedLinesWithFile(String filePath, String expectedText) {
  try {
    assertSameLinesWithFile(filePath, expectedText);
  }
  catch (FileComparisonFailure e) {
    String expected = e.getExpected();
    String actual = e.getActual();
    assertUnorderedElementsAreEqual(expected.split("\n"), actual.split("\n"));
  }
}
 
Example #3
Source File: DefaultPropertyFoldingBuilderTest.java    From litho with Apache License 2.0 5 votes vote down vote up
@Test
public void testFolding() {
  String clsName = "DefaultPropertyFoldingTest.java";

  ApplicationManager.getApplication()
      .invokeAndWait(
          () -> {
            try {
              testHelper.getFixture().testFolding(testHelper.getTestDataPath(clsName));
            } catch (FileComparisonFailure e) {
              Assert.fail("Actual: " + e.getActual());
            }
          });
}