use of org.opentest4j.AssertionFailedError in project JSqlParser by JSQLParser.
the class SpecialOracleTest method testAllSqlsParseDeparse.
@Test
public void testAllSqlsParseDeparse() throws IOException {
int count = 0;
int success = 0;
File[] sqlTestFiles = SQLS_DIR.listFiles();
boolean foundUnexpectedFailures = false;
for (File file : sqlTestFiles) {
if (file.isFile()) {
count++;
String sql = FileUtils.readFileToString(file, Charset.forName("UTF-8"));
try {
assertSqlCanBeParsedAndDeparsed(sql, true);
success++;
recordSuccessOnSourceFile(file);
} catch (JSQLParserException ex) {
String message = ex.getMessage();
int pos = message.indexOf('\n');
if (pos > 0) {
message = message.substring(0, pos);
}
if (sql.contains("@SUCCESSFULLY_PARSED_AND_DEPARSED") || EXPECTED_SUCCESSES.contains(file.getName())) {
LOG.log(Level.SEVERE, "UNEXPECTED PARSING FAILURE: {0}\n\t" + message, file.getName());
foundUnexpectedFailures = true;
} else {
LOG.log(Level.FINE, "EXPECTED PARSING FAILURE: {0}", file.getName());
}
recordFailureOnSourceFile(file, message);
} catch (Exception ex) {
LOG.log(Level.SEVERE, "UNEXPECTED EXCEPTION: {0}\n\t" + ex.getMessage(), file.getName());
foundUnexpectedFailures = true;
} catch (AssertionFailedError ex) {
if (sql.contains("@SUCCESSFULLY_PARSED_AND_DEPARSED") || EXPECTED_SUCCESSES.contains(file.getName())) {
LOG.log(Level.SEVERE, "UNEXPECTED DE-PARSING FAILURE: {0}\n" + ex.toString(), file.getName());
foundUnexpectedFailures = true;
} else {
LOG.log(Level.FINE, "EXPECTED DE-PARSING FAILURE: {0}", file.getName());
}
recordFailureOnSourceFile(file, ex.getActual().getStringRepresentation());
}
}
}
LOG.log(Level.INFO, "tested {0} files. got {1} correct parse results, expected {2}", new Object[] { count, success, EXPECTED_SUCCESSES.size() });
assertTrue(success >= EXPECTED_SUCCESSES.size());
assertFalse(foundUnexpectedFailures, "Found Testcases failing unexpectedly.");
}
use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.
the class ShouldBeEqual_Test method should_use_actual_and_expected_representation_in_AssertionFailedError_actual_and_expected_fields.
@Test
void should_use_actual_and_expected_representation_in_AssertionFailedError_actual_and_expected_fields() {
// GIVEN
byte[] actual = { 1, 2, 3 };
byte[] expected = { 1, 2, 4 };
ThrowingCallable code = () -> then(actual).as("numbers").isEqualTo(expected);
// WHEN
AssertionFailedError error = catchThrowableOfType(code, AssertionFailedError.class);
// THEN
then(error.getActual().getValue()).isEqualTo("[1, 2, 3]");
then(error.getExpected().getValue()).isEqualTo("[1, 2, 4]");
then(error).hasMessage(format("[numbers] %n" + "expected: [1, 2, 4]%n" + " but was: [1, 2, 3]"));
}
use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.
the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_keep_specific_error_message_and_description_set_by_user.
@Test
void should_keep_specific_error_message_and_description_set_by_user() {
// WHEN
AssertionFailedError afe = expectAssertionFailedError(() -> assertion.as("test context").overridingErrorMessage("my %d errors %s", 5, "!").failWithActualExpectedAndMessage(actual, expected, "%d %s", 5, "time"));
// THEN
then(afe).hasMessage("[test context] my 5 errors !");
then(afe.getActual().getEphemeralValue()).isSameAs(actual);
then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.
the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_fail_with_message_having_args.
@Test
void should_fail_with_message_having_args() {
// WHEN
AssertionFailedError afe = expectAssertionFailedError(() -> assertion.failWithActualExpectedAndMessage(actual, expected, "fail %d %s %%s", 5, "times"));
// THEN
then(afe).hasMessage("fail 5 times %s");
then(afe.getActual().getEphemeralValue()).isSameAs(actual);
then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.
the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_fail_with_simple_message.
@Test
void should_fail_with_simple_message() {
// WHEN
AssertionFailedError afe = expectAssertionFailedError(() -> assertion.failWithActualExpectedAndMessage(actual, expected, "fail"));
// THEN
then(afe).hasMessage("fail");
then(afe.getActual().getEphemeralValue()).isSameAs(actual);
then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
Aggregations