Ruang penulis
SEBUAH JURNAL TENTANG TEKNOLOGI

Belajar hal baru.
Tulis. Bagikan.

Ruang untuk merangkai pengetahuan, satu baris kode setiap hari.
Temukan tutorial, ide, dan catatan dari perjalanan belajar.

1914 catatan & terus bertumbuh
PILIHAN EDITOR
Java

Memahami Java Stream: olah koleksi dengan lebih ringkas

Pelajari alur filter, map, dan collect untuk mengolah data Java dengan kode yang mudah dibaca.

D Tim Diary Coding · 1 menit baca
UNTUK RASA INGIN TAHUMU

Catatan terbaru.

JUNIT / CATATAN</>
JUnit13 Jul 2026

How do I write tests for utility classes?

Utility classes are usually tested like any other unit: test their public behavior, especially calculations, transformations, validation rules, edge cases, and error handling. The main difference is that utility classes often have static methods, so your tests usually call the method directly instead of creating an object. 1. Test Useful Behavior, Not the Fact That […]

Wayan · 7 menit baca
JUNIT / CATATAN</>
JUnit12 Jul 2026

How do I structure unit tests in a real Java project?

In a real Java project, unit tests should be organized so they are easy to find, run, understand, and maintain. A good structure follows the same shape as your production code and keeps tests focused on behavior. Most Java projects use this standard layout: project-root ├── src │ ├── main │ │ └── java │ […]

Wayan · 12 menit baca
JUNIT / CATATAN</>
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 menit baca
JUNIT / CATATAN</>
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 menit baca
JUNIT / CATATAN</>
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 menit baca
JUNIT / CATATAN</>
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 menit baca

Pengetahuan tumbuh ketika dibagikan.

Simpan rasa ingin tahu. Selalu ada hal baru untuk dipelajari.

Jelajahi catatan ↗
Putu Adi Guna Permana
TENTANG PENULIS

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

Penulis dan pendiri Diary Coding — berbagi catatan, tutorial, dan pengalaman seputar pemrograman untuk siapa pun yang ingin terus belajar.