November 2024
Intermediate to advanced
300 pages
7h 12m
English
The bulk of your assertions will use either assertTrue or assertEquals. Let’s review and refine your knowledge of these two assertion workhorses. Let’s also see how to keep your tests streamlined by eliminating things that don’t add value.
The most basic assert form accepts a Boolean expression or reference as an argument and fails the test if that argument evaluates to false.
| | org.junit.jupiter.api.Assertions.assertTrue(someBooleanExpression); |
Here’s an example demonstrating the use of assertTrue:
| | @Test |
| | void hasPositiveBalanceAfterInitialDeposit() { |
| | var account = new Account("an account name"); |
| | |
| | account.deposit(50); ... |
Read now
Unlock full access