use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Integers_assertIsCloseTo_Test method should_fail_if_actual_is_not_close_enough_to_expected.
@Test
@DataProvider({ "1, 3, 1", "3, 1, 1", "-2, 0, 1", "-1, 1, 1", "0, 2, 1" })
public void should_fail_if_actual_is_not_close_enough_to_expected(int actual, int expected, int offset) {
AssertionInfo info = someInfo();
try {
integers.assertIsCloseTo(info, actual, expected, within(offset));
} catch (AssertionError e) {
verify(failures).failure(info, shouldBeEqual(actual, expected, within(offset), abs(actual - expected)));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Integers_assertIsNotCloseToPercentage_Test method should_fail_if_difference_is_equal_to_given_percentage.
@Test
@DataProvider({ "1, 1, 0", "2, 1, 100", "1, 2, 50", "-1, -1, 0", "-2, -1, 100", "-1, -2, 50" })
public void should_fail_if_difference_is_equal_to_given_percentage(Integer actual, Integer other, Integer percentage) {
AssertionInfo info = someInfo();
try {
integers.assertIsNotCloseToPercentage(someInfo(), actual, other, withPercentage(percentage));
} catch (AssertionError e) {
verify(failures).failure(info, shouldNotBeEqualWithinPercentage(actual, other, withPercentage(percentage), abs(actual - other)));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Integers_assertNotEqual_Test method should_fail_if_integers_are_equal.
@Test
public void should_fail_if_integers_are_equal() {
AssertionInfo info = someInfo();
try {
integers.assertNotEqual(info, 6, 6);
} catch (AssertionError e) {
verify(failures).failure(info, shouldNotBeEqual(6, 6));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Iterables_assertAreExactly_Test method should_fail_if_condition_is_met_much.
@Test
public void should_fail_if_condition_is_met_much() {
testCondition.shouldMatch(false);
AssertionInfo info = someInfo();
try {
actual = newArrayList("Yoda", "Luke", "Obiwan");
iterables.assertAreExactly(someInfo(), actual, 2, jedi);
} catch (AssertionError e) {
verify(conditions).assertIsNotNull(jedi);
verify(failures).failure(info, elementsShouldBeExactly(actual, 2, jedi));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Iterables_assertAreNot_Test method should_fail_if_condition_is_met.
@Test
public void should_fail_if_condition_is_met() {
testCondition.shouldMatch(false);
AssertionInfo info = someInfo();
try {
actual = newArrayList("Solo", "Leia", "Yoda");
iterables.assertAreNot(someInfo(), actual, jedi);
} catch (AssertionError e) {
verify(conditions).assertIsNotNull(jedi);
verify(failures).failure(info, elementsShouldNotBe(actual, newArrayList("Yoda"), jedi));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
Aggregations