Class Assertions


  • public final class Assertions
    extends Object
    A collection of methods providing assertions useful in tests. These supplement the standard set of test assertions provided by a testing framework such as JUnit.
    • Method Detail

      • assertLinesEqual

        public static void assertLinesEqual​(String expectedOutput,
                                            String actualOutput)
        Compares two files, line-by-line. The newline style ( windows vs. unix ) is not considered by the comparison.
        Parameters:
        expectedOutput - The expected output file
        actualOutput - The actual output file
      • assertLinesEqual

        public static void assertLinesEqual​(String expectedOutput,
                                            String actualOutput,
                                            Assertions.MismatchFilter filter)
        Compares two files, line-by-line. The newline style ( windows vs. unix ) is not considered by the comparison.
        Parameters:
        expectedOutput - The expected output file
        actualOutput - The actual output file
        filter - Mismatching lines are handed to this filter to determine whether the mismatch is to be considered significant
      • assertDirectoriesEqual

        public static final void assertDirectoriesEqual​(String expectedPath,
                                                        String actualPath)
        Compares all files in the two directories, line-by-line, using assertLinesEqual(String, String).
        Parameters:
        expectedPath - the directory containing the expected files
        actualPath - the directory containing the actual files
      • assertDirectoriesEqual

        public static void assertDirectoriesEqual​(File expectedPath,
                                                  File actualPath)
        Compares all files in the two directories, line-by-line, using assertLinesEqual(String, String).
        Parameters:
        expectedPath - the directory containing the expected files
        actualPath - the directory containing the actual files
      • assertDirectoriesEqual

        public static void assertDirectoriesEqual​(File expectedPath,
                                                  File actualPath,
                                                  Assertions.MismatchFilter mismatchFilter)
        Compares all files in the two directories, line-by-line, using assertLinesEqual(String, String, MismatchFilter).
        Parameters:
        expectedPath - the directory containing the expected files
        actualPath - the directory containing the actual files
        mismatchFilter - Mismatching lines are handed to this filter to determine whether the mismatch is to be considered significant
      • assertEquals

        public static void assertEquals​(String expected,
                                        String actual)
      • assertEquals

        public static void assertEquals​(Object expected,
                                        Object actual)
      • assertArrayEquals

        public static void assertArrayEquals​(Object[] expecteds,
                                             Object[] actuals)
      • assertTrue

        public static void assertTrue​(boolean condition)
      • assertTrue

        public static void assertTrue​(String message,
                                      boolean condition)