From the course: Java: Testing with JUnit
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Assertions
- [Instructor] Assertions are used to check a certain condition. If an assertion fails, the test fails. We can find the assertions in the assertions class in the org.junit.jupiter.api package. We usually use a static import for this one so that we can use all the methods without having the assertions. in front of them. There are very many methods inside this class, and they're all used to perform the actual tests. We have seen one already, assertEquals. We can see it here on line 12 and line 20. This one checks whether a certain expected outcome is equal to a certain actual outcome, and if that is the case, the test will pass. If it's not the case, the test will fail. There are very many overloads available for assertEquals, and that's not only true for assertEquals. It's actually the case for all the assertion methods inside the assertions class. Java will know which one is the closest match, and that is the assertion…