SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

JUNIT / NOTES</>↗
JUnit08 Jul 2026

How do I group multiple assertions with assertAll()?

In JUnit 5, you can group multiple assertions using assertAll(). This lets JUnit run all assertions in the group, even if one fails, and then report all failures together. Basic Syntax import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class UserTest { @Test void testUserDetails() { User user = new User("Alice", 25, "alice@example.com"); assertAll("User details", () -> assertEquals("Alice", […]

Wayan · 3 min read
JUNIT / NOTES</>↗
JUnit08 Jul 2026

How do I test null and non-null values in JUnit?

To test null and non-null values in JUnit, use these assertions: assertNull(value) — passes if the value is null assertNotNull(value) — passes if the value is not null In JUnit 5, these methods are available from org.junit.jupiter.api.Assertions. Basic Example import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNotNull; class NullCheckTest { @Test void valueShouldBeNull() { String [...

Wayan · 3 min read
JUNIT / NOTES</>↗
JUnit08 Jul 2026

How do I test boolean conditions with assertTrue() and assertFalse()?

Use assertTrue() when you expect a boolean condition to be true, and assertFalse() when you expect it to be false. They are JUnit assertions, most commonly used in JUnit 5 like this: import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; class BooleanConditionTest { @Test void shouldCheckBooleanConditions() { String message = "Hello JUnit"; assertTrue(message.contains("JUnit"));...

Wayan · 2 min read
JUNIT / NOTES</>↗
JUnit08 Jul 2026

How do I test expected values with assertEquals()?

In JUnit, you use assertEquals() to test whether an actual value matches an expected value. The basic syntax is: assertEquals(expectedValue, actualValue); The first argument is what you expect. The second argument is what your code actually produced. Basic Example import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class CalculatorTest { @Test void shouldAddTwoNumbers() { int result = 2 […]

Wayan · 2 min read
JUNIT / NOTES</>↗
JUnit07 Jul 2026

How do I use assertions in JUnit?

In JUnit, assertions are used to verify that your code produces the expected result. If an assertion fails, the test fails. JUnit 5 assertions are provided by the org.junit.jupiter.api.Assertions class. Basic Example import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class CalculatorTest { @Test void testAddition() { int result = 2 + 3; assertEquals(5, result); } } In […]

Wayan · 5 min read
JUNIT / NOTES</>↗
JUnit07 Jul 2026

How do I use @Test in JUnit?

Using @Test in JUnit In JUnit, @Test is an annotation that marks a method as a test method. When you run your tests, JUnit looks for methods annotated with @Test and executes them automatically. 1. Add the Correct Import For JUnit 5, use: import org.junit.jupiter.api.Test; You will usually also import assertions such as: import static […]

Wayan · 3 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.