Open hobovsky opened 2 years ago
I would suggest to add also display names:
import org.junit.jupiter.api.DisplayName;
@DisplayName("Tests with JUnit 5")
class SampleTests {
@ParameterizedTest(name = "input: '{0}' and I expect you to return >>{1}<<")
@DisplayName("We test some fixed Strings")
@CsvSource({"test,TEST", "tEst,TEST"})
void toUpperCase_ShouldGenerateTheExpectedUppercaseValue(String input, String expected) {
String actualValue = input.toUpperCase();
assertEquals(expected, actualValue);
}
}
This will lead to the following output:
Finally readable parametrized tests in java...? XD
What about the order of the test methods?
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class SampleTests {
@Test
@Order(2)
void secondTest() { ... }
@Test
@Order(1)
void firstTest() { ... }
}
Other built-in possibilities are
MethodOrderer.Alphanumeric
MethodOrderer.DisplayName
(since 5.7, still experimental in latest 5.8.2)MethodOrderer.MethodName
(since 5.7, still experimental in latest 5.8.2)MethodOrderer.Random
CW currently uses JUnit 5.4.0