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</>
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 menit baca
JUNIT / CATATAN</>
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 menit baca
JUNIT / CATATAN</>
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 menit baca
JUNIT / CATATAN</>
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 menit baca
JUNIT / CATATAN</>
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 menit baca
JUNIT / CATATAN</>
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 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.