Java Code Examples for junit.framework.AssertionFailedError#getMessage()

The following examples show how to use junit.framework.AssertionFailedError#getMessage() . 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: TestLang.java    From Digital with GNU General Public License v3.0 6 votes vote down vote up
private void parseTree(File file, HashSet<String> keys) throws IOException {
    File[] files = file.listFiles();
    if (files != null)
        for (File f : files) {
            if (f.isDirectory() && f.getName().charAt(0) != '.')
                parseTree(f, keys);
            if (f.isFile()) {
                try {
                    if (f.getName().endsWith(".java"))
                        checkSourceFile(f, keys, PATTERN);
                    if (f.getName().endsWith(".tem") || f.getName().endsWith(".v"))
                        checkSourceFile(f, keys, TEM_PATTERN);
                } catch (AssertionFailedError e) {
                    throw new AssertionFailedError(e.getMessage() + " in file " + f);
                }
            }
        }
}
 
Example 2
Source File: PlatformTestUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void assertTiming(String message, long expected, int attempts, @Nonnull Runnable actionToMeasure) {
  while (true) {
    attempts--;
    long duration = measure(actionToMeasure);
    try {
      assertTiming(message, expected, duration);
      break;
    }
    catch (AssertionFailedError e) {
      if (attempts == 0) throw e;
      System.gc();
      System.gc();
      System.gc();
      String s = "Another epic fail (remaining attempts: " + attempts + "): " + e.getMessage();
      TeamCityLogger.warning(s, null);
      System.err.println(s);
    }
  }
}
 
Example 3
Source File: DataFolderSetOrderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** If execution fails we wrap the exception with 
 * new log message.
 */
protected void runTest () throws Throwable {
    ErrManager.messages.append ("Starting test ");
    ErrManager.messages.append (getName ());
    ErrManager.messages.append ('\n');
    
    try {
        super.runTest ();
    } catch (AssertionFailedError ex) {
        AssertionFailedError ne = new AssertionFailedError (ex.getMessage () + " Log:\n" + ErrManager.messages);
        ne.setStackTrace (ex.getStackTrace ());
        throw ne;
    }
}
 
Example 4
Source File: TestLang.java    From Digital with GNU General Public License v3.0 5 votes vote down vote up
private void checkSourceFile(File f, HashSet<String> keys, String pattern) throws IOException {
    try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8))) {
        int linecount = 0;
        String line;
        while ((line = r.readLine()) != null) {
            linecount++;
            try {
                checkSourceLine(line, keys, pattern);
            } catch (AssertionFailedError e) {
                throw new AssertionFailedError(e.getMessage() + " in line " + linecount);
            }
        }
    }
}
 
Example 5
Source File: AssertTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testAssertNullNotEqualsNull() {
	try {
		assertEquals(null, new Object());
	} catch (AssertionFailedError e) {
		e.getMessage(); // why no assertion?
		return;
	}
	fail();
}
 
Example 6
Source File: DefaultFunctionsTest.java    From jackcess with Apache License 2.0 5 votes vote down vote up
private static void assertEvalFormat(String fmtStr, String... testStrs) {
  for(int i = 0; i < testStrs.length; i+=2) {
    String expected = testStrs[i];
    String val = testStrs[i + 1];

    try {
      assertEval(expected,
                 "=Format(" + val + ", " + fmtStr + ")");
    } catch(AssertionFailedError afe) {
      throw new AssertionFailedError("Input " + val + ": " +
                                     afe.getMessage());
    }
  }
}