How do you assert that a number is positive in AssertJ?
A) isPositive()
B) isGreaterThanZero()
C) isNonNegative()
D) isAboveZero()
Answer:
A) isPositive()
Explanation:
The isPositive()
method in AssertJ is used to assert that a number is positive. It checks whether the number is greater than zero.
For example:
import static org.assertj.core.api.Assertions.assertThat;
int number = 5;
assertThat(number).isPositive();
In this example, the isPositive()
method asserts that the number number
is positive.