Aller au contenu

Test Method Naming (ARCH4008)

Ce contenu n’est pas encore disponible dans votre langue.

Key java.naming.test-name-convention · Severity info · Category naming

Test methods should follow the test framework’s discovery/naming convention so they are picked up and read consistently.

class OrderServiceTest {
@Test
void t1() { // meaningless name
assertEquals(2, calc(1, 1));
}
}
class OrderServiceTest {
@Test
void calc_addsTwoNumbers_returnsSum() {
assertEquals(2, calc(1, 1));
}
}

Name test methods with a descriptive convention such as “method_scenario_expected”.