How do you assert that a number is positive in AssertJ?

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.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top