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</>↗
JUnit10 Jul 2026

How do I disable a test with @Disabled annotation?

In JUnit 5, you can disable a test by annotating it with @Disabled from the org.junit.jupiter.api package. Disable a Single Test Method import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; class CalculatorTest { @Test @Disabled void divisionByZeroTest() { // This test will be skipped } } When you run the test suite, this test will not be executed. Add […]

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

How do I understand the JUnit test lifecycle?

The JUnit test lifecycle describes the order in which JUnit creates test objects, runs setup code, executes test methods, and performs cleanup. Understanding this lifecycle helps you write tests that are clean, predictable, and easy to maintain. This guide focuses on JUnit 5, also known as JUnit Jupiter. 1. What Is the JUnit Test Lifecycle? […]

Wayan · 8 min read
JUNIT / NOTES</>↗
JUnit09 Jul 2026

How do I use @BeforeAll and @AfterAll in JUnit?

In JUnit 5, @BeforeAll and @AfterAll are lifecycle annotations used to run setup and cleanup code once per test class. They are useful when you need to initialize or clean up expensive shared resources, such as: database connections test containers temporary directories mock servers shared test data application-wide configuration Basic Rule By default, methods annotated […]

Wayan · 4 min read
JUNIT / NOTES</>↗
JUnit09 Jul 2026

How do I use @BeforeEach and @AfterEach in JUnit?

In JUnit 5, @BeforeEach and @AfterEach are lifecycle annotations. They let you run code before and after every test method. Annotation When it runs Common use @BeforeEach Before each @Test method Create objects, initialize test data, reset state @AfterEach After each @Test method Clean up resources, close files/connections, reset temporary state Basic Example import org.junit.jupiter.api.AfterEach; […]

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

How do I understand test naming conventions in JUnit?

JUnit itself does not require one specific naming convention for test methods, especially in JUnit 5. A test method is recognized because it is annotated with @Test, not because of its name. That said, good test names are crucial because they explain what behavior is being tested. 1. Test Class Naming A common convention is […]

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

How do I test exceptions with assertThrows()?

Testing Exceptions with assertThrows() in JUnit 5 Use assertThrows() when you expect a piece of code to throw a specific exception. Basic Syntax ExceptionType exception = assertThrows( ExceptionType.class, () -> { // code that should throw the exception } ); For JUnit 5, import it like this: import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertThrows; Simple Example import […]

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.