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

How do I test private logic without testing private methods directly?

The best way to test private logic is to test the observable behavior that depends on it, usually through the class’s public methods. Private methods are implementation details. If you test them directly, your tests become tightly coupled to how the class is written internally. That makes refactoring harder because changing a private method can […]

Wayan · 6 min read
JUNIT / NOTES</>↗
JUnit12 Jul 2026

How do I test code that depends on time?

Code that depends directly on the current date or time can be difficult to test because the result changes every time the test runs. For example, code like this is hard to test reliably: import java.time.LocalDate; public class SubscriptionService { public boolean isExpired(LocalDate expiryDate) { return expiryDate.isBefore(LocalDate.now()); } } The problem is LocalDate.now(). Today’s test […]

Wayan · 6 min read
JUNIT / NOTES</>↗
JUnit12 Jul 2026

How do I use assumptions in JUnit tests?

In JUnit 5, assumptions let you run a test only when certain conditions are true. If an assumption fails, the test is skipped/aborted, not failed. They are useful when a test depends on things like: operating system environment variables external services database availability specific Java version local developer setup JUnit assumptions are available from: import […]

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

How do I write repeated tests in JUnit?

In JUnit 5, repeated tests are written using the @RepeatedTest annotation. A repeated test runs the same test method multiple times without requiring different input values. Basic Example import org.junit.jupiter.api.RepeatedTest; import static org.junit.jupiter.api.Assertions.assertTrue; class RandomNumberTest { @RepeatedTest(5) void randomNumberShouldBeLessThanTen() { int number = (int) (Math.random() * 10); assertTrue(number >= 0 && number < 10); } […]

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

How do I run only selected JUnit tests by tag?

To run only selected JUnit 5 tests by tag, mark your tests with @Tag, then configure your build tool or IDE to include only that tag. 1. Add tags to your tests import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; class PaymentServiceTest { @Test @Tag("fast") void calculatesTotal() { // test code } @Test @Tag("integration") void connectsToPaymentGateway() { // test […]

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

How do I use tags to group JUnit tests?

In JUnit 5, you can use the @Tag annotation to group tests into categories such as: fast slow unit integration database api smoke Tags are useful when you want to run only certain groups of tests, for example only fast unit tests during development, or only integration tests in a CI pipeline. 1. Basic Example […]

Wayan · 5 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.