3. Introduction to JUnit 5 | Java Tutorial | Assertions | Learn Programming

Опубликовано: 16 Сентябрь 2026
на канале: ModelMyMind
874
38

Hello everyone,

Welcome to ModelMyMind, your computer science channel!

Today we continue with the topic of #junit, or more specifically, assertions. We'll pick up right where we left off in the last video.

In today's video, we'll look at some essential methods of the Assertions class.

With assertions, we can make logical statements that we assume to be true.

We'll look at different methods, including:

assertSame(): The assertSame() method tests whether two object references point to the same object.

assertNotSame(): The assertNotSame() method tests whether two object references do not point to the same object.

assertNull(): The assertNull() method checks whether a passed parameter is null. If it is not null, the test fails.

assertNotNull(): This method checks whether a passed parameter is null. Furthermore, by default, test methods do not follow a specific order. This means that test cases are not necessarily executed in the order they were written. In other words, JUnit executes test methods in a deterministic, but unpredictable, order.

However, JUnit offers the option to define the execution order for test cases. We will learn about this in the video.

#java #computer science