Is there anyway to assert that,
actual int value = expected int value not equal to 0
Something like,
Assert.assertEquals(length, 0);
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communitypublic static void assertEquals(int actual,
int expected,
java.lang.String message)
Asserts that two ints are equal. If they are not, an AssertionFailedError, with the given message, is thrown. Parameters: actual - the actual value expected - the expected value message - the assertion error message
The TestNG Assert documentation describes a function assertNotEquals
Assert.assertNotEquals(length, 0);
This does what you want I guess, if not you can also check with assertEquals with some extra code.
Pseudo code:
result = false
if (length == 0 ) {
result = true
}
Assert.assertEquals(result, false)
I would use assertThat
instead of simple assertEquals
or assertNotEquals
for the reasons described on Stackoverflow:
assertThat(actual, is(not(equalTo(expected)));
assertThat(actual, is(not(equalTo(0)));
Assert.assertTrue(actIntValue==expIntValue && expIntValue > 0);