use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.
the class AssertEqualsAssertionsTests method assertEqualsFloatWithDeltaWithUnequalValuesAndMessage.
@Test
void assertEqualsFloatWithDeltaWithUnequalValuesAndMessage() {
Executable assertion = () -> assertEquals(0.5f, 0.45f, 0.03f, "message");
AssertionFailedError e = assertThrows(AssertionFailedError.class, assertion);
assertMessageStartsWith(e, "message");
assertMessageEndsWith(e, "expected: <0.5> but was: <0.45>");
assertExpectedAndActualValues(e, 0.5f, 0.45f);
}
use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.
the class AssertEqualsAssertionsTests method assertEqualsFloatWithDeltaWithUnequalValuesAndMessageSupplier.
@Test
void assertEqualsFloatWithDeltaWithUnequalValuesAndMessageSupplier() {
Executable assertion = () -> assertEquals(0.5f, 0.45f, 0.03f, () -> "message");
AssertionFailedError e = assertThrows(AssertionFailedError.class, assertion);
assertMessageStartsWith(e, "message");
assertMessageEndsWith(e, "expected: <0.5> but was: <0.45>");
assertExpectedAndActualValues(e, 0.5f, 0.45f);
}
use of org.opentest4j.AssertionFailedError in project aws-mysql-jdbc by awslabs.
the class MetaDataRegressionTest method testBug20491.
@Test
public void testBug20491() throws Exception {
this.rs = this.stmt.executeQuery("SHOW VARIABLES LIKE '%char%'");
while (this.rs.next()) {
System.out.println(this.rs.getString(1) + " = " + this.rs.getString(2));
}
this.rs.close();
String[] fields = { "field1_ae_\u00e4", "field2_ue_\u00fc", "field3_oe_\u00f6", "field4_sz_\u00df" };
createTable("tst", "(`" + fields[0] + "` int(10) unsigned NOT NULL default '0', `" + fields[1] + "` varchar(45) default '', `" + fields[2] + "` varchar(45) default '', `" + fields[3] + "` varchar(45) default '', PRIMARY KEY (`" + fields[0] + "`))");
for (int i = 0; i < fields.length; i++) {
try {
assertEquals(fields[i], new String(fields[i].getBytes("Cp1252"), "Cp1252"));
} catch (AssertionFailedError afEr) {
if (i == 3) {
if (!Constants.OS_NAME.startsWith("Mac")) {
throw afEr;
}
}
}
}
@SuppressWarnings("unused") byte[] asBytes = fields[0].getBytes("utf-8");
DatabaseMetaData md = this.conn.getMetaData();
this.rs = md.getColumns(this.dbName, "%", "tst", "%");
int j = 0;
while (this.rs.next()) {
try {
assertEquals(fields[j++], this.rs.getString(4), "Wrong column name:" + this.rs.getString(4));
} catch (AssertionFailedError afEr) {
if (j == 3) {
if (!Constants.OS_NAME.startsWith("Mac")) {
throw afEr;
}
}
}
}
this.rs.close();
this.rs = this.stmt.executeQuery("SELECT * FROM tst");
ResultSetMetaData rsmd = this.rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
try {
assertEquals(fields[i - 1], rsmd.getColumnName(i), "Wrong column name:" + rsmd.getColumnName(i));
} catch (AssertionFailedError afEr) {
if (i - 1 == 3) {
if (!Constants.OS_NAME.startsWith("Mac")) {
throw afEr;
}
}
}
}
}
use of org.opentest4j.AssertionFailedError in project sonar-java by SonarSource.
the class RegexParserTestUtils method assertSuccessfulParse.
public static RegexTree assertSuccessfulParse(String regex) {
RegexSource source = makeSource(regex);
RegexParseResult result = new RegexParser(source, new FlagSet()).parse();
if (!result.getSyntaxErrors().isEmpty()) {
throw new AssertionFailedError("Parsing should complete with no errors.", "no errors", result.getSyntaxErrors());
}
return result.getResult();
}
use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.
the class OptionalAssert_contains_Test method should_fail_if_optional_does_not_contain_expected_value.
@Test
void should_fail_if_optional_does_not_contain_expected_value() {
// GIVEN
Optional<String> actual = Optional.of("not-expected");
String expectedValue = "something";
// WHEN
AssertionFailedError error = catchThrowableOfType(() -> assertThat(actual).contains(expectedValue), AssertionFailedError.class);
// THEN
assertThat(error).hasMessage(shouldContain(actual, expectedValue).create());
assertThat(error.getActual().getStringRepresentation()).isEqualTo(actual.get());
assertThat(error.getExpected().getStringRepresentation()).isEqualTo(expectedValue);
}
Aggregations