What method is used in AssertJ to check if a string is empty?

What method is used in AssertJ to check if a string is empty?

A) isEmpty()
B) isNull()
C) isBlank()
D) isNotNull()

Answer:

A) isEmpty()

Explanation:

The isEmpty() method in AssertJ is used to assert that a string is empty. It checks whether the string contains no characters.

For example:


import static org.assertj.core.api.Assertions.assertThat;

String emptyString = "";

assertThat(emptyString).isEmpty();

In this example, the isEmpty() method asserts that the string emptyString is empty.

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