本文整理了Java中org.testng.Assert.failNotEquals()
方法的一些代码示例,展示了Assert.failNotEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.failNotEquals()
方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:failNotEquals
暂无
代码示例来源:origin: org.testng/testng
/**
* Asserts that a condition is false. If it isn't,
* an AssertionError, with the given message, is thrown.
* @param condition the condition to evaluate
* @param message the assertion error message
*/
public static void assertFalse(boolean condition, String message) {
if(condition) {
failNotEquals(condition, Boolean.FALSE, message); // TESTNG-81
}
}
代码示例来源:origin: org.testng/testng
/**
* Asserts that a condition is true. If it isn't,
* an AssertionError, with the given message, is thrown.
* @param condition the condition to evaluate
* @param message the assertion error message
*/
public static void assertTrue(boolean condition, String message) {
if(!condition) {
failNotEquals(condition, Boolean.TRUE, message);
}
}
代码示例来源:origin: cbeust/testng
/**
* Asserts that a condition is true. If it isn't, an AssertionError, with the given message, is
* thrown.
*
* @param condition the condition to evaluate
* @param message the assertion error message
*/
public static void assertTrue(boolean condition, String message) {
if (!condition) {
failNotEquals(condition, Boolean.TRUE, message);
}
}
代码示例来源:origin: cbeust/testng
/**
* Asserts that a condition is false. If it isn't, an AssertionError, with the given message, is
* thrown.
*
* @param condition the condition to evaluate
* @param message the assertion error message
*/
public static void assertFalse(boolean condition, String message) {
if (condition) {
failNotEquals(condition, Boolean.FALSE, message); // TESTNG-81
}
}
代码示例来源:origin: org.testng/testng
/**
* Differs from {@link #assertEquals(Object, Object, String)} by not taking arrays into
* special consideration hence comparing them by reference. Intended to be called directly
* to test equality of collections content.
*/
private static void assertEqualsImpl(Object actual, Object expected,
String message) {
if((expected == null) && (actual == null)) {
return;
}
if(expected == null ^ actual == null) {
failNotEquals(actual, expected, message);
}
if (expected.equals(actual) && actual.equals(expected)) {
return;
}
failNotEquals(actual, expected, message);
}
代码示例来源:origin: org.testng/testng
/**
* Asserts that two floats are equal concerning a delta. If they are not,
* an AssertionError, with the given message, is thrown. If the expected
* value is infinity then the delta value is ignored.
* @param actual the actual value
* @param expected the expected value
* @param delta the absolute tolerable difference between the actual and expected values
* @param message the assertion error message
*/
public static void assertEquals(float actual, float expected, float delta, String message) {
// handle infinity specially since subtracting to infinite values gives NaN and the
// the following test fails
if(Float.isInfinite(expected)) {
if(!(expected == actual)) {
failNotEquals(actual, expected, message);
}
}
else if(!(Math.abs(expected - actual) <= delta)) {
failNotEquals(actual, expected, message);
}
}
代码示例来源:origin: org.testng/testng
/**
* Assert set equals
*/
public static void assertEquals(Set<?> actual, Set<?> expected, String message) {
if (actual == expected) {
return;
}
if (actual == null || expected == null) {
// Keep the back compatible
if (message == null) {
fail("Sets not equal: expected: " + expected + " and actual: " + actual);
} else {
failNotEquals(actual, expected, message);
}
}
if (!actual.equals(expected)) {
if (message == null) {
fail("Sets differ: expected " + expected + " but got " + actual);
} else {
failNotEquals(actual, expected, message);
}
}
}
代码示例来源:origin: org.testng/testng
/**
* Asserts that two doubles are equal concerning a delta. If they are not,
* an AssertionError, with the given message, is thrown. If the expected
* value is infinity then the delta value is ignored.
* @param actual the actual value
* @param expected the expected value
* @param delta the absolute tolerable difference between the actual and expected values
* @param message the assertion error message
*/
public static void assertEquals(double actual, double expected, double delta, String message) {
// handle infinity specially since subtracting to infinite values gives NaN and the
// the following test fails
if(Double.isInfinite(expected)) {
if(!(expected == actual)) {
failNotEquals(actual, expected, message);
}
}
else if (Double.isNaN(expected)) {
if (!Double.isNaN(actual)) {
failNotEquals(actual, expected, message);
}
}
else if(!(Math.abs(expected - actual) <= delta)) {
failNotEquals(actual, expected, message);
}
}
代码示例来源:origin: cbeust/testng
/**
* Asserts that two doubles are equal. If they are not, an AssertionError, with the given message,
* is thrown.
*
* @param actual the actual value
* @param expected the expected value
* @param message the assertion error message
*/
public static void assertEquals(double actual, double expected, String message) {
if (Double.isNaN(expected)) {
if (!Double.isNaN(actual)) {
failNotEquals(actual, expected, message);
}
} else if (actual != expected) {
failNotEquals(actual, expected, message);
}
}
代码示例来源:origin: cbeust/testng
/**
* Asserts that two floats are equal. If they are not, an AssertionError, with the given message,
* is thrown.
*
* @param actual the actual value
* @param expected the expected value
* @param message the assertion error message
*/
public static void assertEquals(float actual, float expected, String message) {
if (Float.isNaN(expected)) {
if (!Float.isNaN(actual)) {
failNotEquals(actual, expected, message);
}
} else if (actual != expected) {
failNotEquals(actual, expected, message);
}
}
代码示例来源:origin: cbeust/testng
/** Assert set equals */
public static void assertEquals(Set<?> actual, Set<?> expected, String message) {
if (actual == expected) {
return;
}
if (actual == null || expected == null) {
// Keep the back compatible
if (message == null) {
fail("Sets not equal: expected: " + expected + " and actual: " + actual);
} else {
failNotEquals(actual, expected, message);
}
}
if (!actual.equals(expected)) {
if (message == null) {
fail("Sets differ: expected " + expected + " but got " + actual);
} else {
failNotEquals(actual, expected, message);
}
}
}
代码示例来源:origin: cbeust/testng
/**
* Asserts that two doubles are equal concerning a delta. If they are not, an AssertionError, with
* the given message, is thrown. If the expected value is infinity then the delta value is
* ignored.
*
* @param actual the actual value
* @param expected the expected value
* @param delta the absolute tolerable difference between the actual and expected values
* @param message the assertion error message
*/
public static void assertEquals(double actual, double expected, double delta, String message) {
// handle infinity specially since subtracting to infinite values gives NaN and the
// the following test fails
if (Double.isInfinite(expected)) {
if (!(expected == actual)) {
failNotEquals(actual, expected, message);
}
} else if (Double.isNaN(expected)) {
if (!Double.isNaN(actual)) {
failNotEquals(actual, expected, message);
}
} else if (!(Math.abs(expected - actual) <= delta)) {
failNotEquals(actual, expected, message);
}
}
代码示例来源:origin: org.testng/testng
private static void assertArrayEquals(Object actual, Object expected, String message) {
if (expected == actual) {
return;
}
if (null == expected) {
fail("expected a null array, but not null found. " + message);
}
if (null == actual) {
fail("expected not null array, but null found. " + message);
}
//is called only when expected is an array
if (!actual.getClass().isArray()) {
failNotEquals(actual, expected, message);
}
int expectedLength = Array.getLength(expected);
if (expectedLength != Array.getLength(actual)) {
failNotEquals(Array.getLength(actual), expectedLength, message == null ? "" : message
+ " (Array lengths are not the same)");
}
for (int i = 0; i < expectedLength; i++) {
Object _actual = Array.get(actual, i);
Object _expected = Array.get(expected, i);
try {
assertEquals(_actual, _expected);
} catch (AssertionError ae) {
failNotEquals(actual, expected, message == null ? "" : message
+ " (values at index " + i + " are not the same)");
}
}
}
代码示例来源:origin: cbeust/testng
/**
* Asserts that two floats are equal concerning a delta. If they are not, an AssertionError, with
* the given message, is thrown. If the expected value is infinity then the delta value is
* ignored.
*
* @param actual the actual value
* @param expected the expected value
* @param delta the absolute tolerable difference between the actual and expected values
* @param message the assertion error message
*/
public static void assertEquals(float actual, float expected, float delta, String message) {
// handle infinity specially since subtracting to infinite values gives NaN and the
// the following test fails
if (Float.isInfinite(expected)) {
if (!(expected == actual)) {
failNotEquals(actual, expected, message);
}
} else if (Float.isNaN(expected)) {
if (!Float.isNaN(actual)) {
failNotEquals(actual, expected, message);
}
} else if (!(Math.abs(expected - actual) <= delta)) {
failNotEquals(actual, expected, message);
}
}
代码示例来源:origin: org.testng/testng
public static void assertEqualsDeep(Set<?> actual, Set<?> expected, String message) {
if (actual == expected) {
return;
}
if (actual == null || expected == null) {
// Keep the back compatible
if (message == null) {
fail("Sets not equal: expected: " + expected + " and actual: " + actual);
} else {
failNotEquals(actual, expected, message);
}
}
Iterator<?> actualIterator = actual.iterator();
Iterator<?> expectedIterator = expected.iterator();
while (expectedIterator.hasNext()) {
Object expectedValue = expectedIterator.next();
if (!actualIterator.hasNext()) {
fail("Sets not equal: expected: " + expected + " and actual: " + actual);
}
Object value = actualIterator.next();
if (expectedValue.getClass().isArray()) {
assertArrayEquals(value, expectedValue, message);
} else {
assertEqualsImpl(value, expectedValue, message);
}
}
}
代码示例来源:origin: cbeust/testng
/**
* Differs from {@link #assertEquals(Object, Object, String)} by not taking arrays into special
* consideration hence comparing them by reference. Intended to be called directly to test
* equality of collections content.
*/
private static void assertEqualsImpl(Object actual, Object expected, String message) {
if ((expected == null) && (actual == null)) {
return;
}
if (expected == null ^ actual == null) {
failNotEquals(actual, expected, message);
}
if (expected.equals(actual) && actual.equals(expected)) {
return;
}
fail(format(actual, expected, message, true));
}
代码示例来源:origin: cbeust/testng
failNotEquals(actual, expected, message);
failNotEquals(
Array.getLength(actual),
expectedLength,
assertEquals(_actual, _expected);
} catch (AssertionError ae) {
failNotEquals(
actual,
expected,
代码示例来源:origin: cbeust/testng
fail("Sets not equal: expected: " + expected + " and actual: " + actual);
} else {
failNotEquals(actual, expected, message);
代码示例来源:origin: cbeust/testng
failNotEquals(a, e, message);
内容来源于网络,如有侵权,请联系作者删除!