98 Výpis 6.6:
JUnit 5 – JednotkovĂŠ testovĂĄnĂ na platformÄ› Java Definice testovacĂ tĹ™Ădy TestParamDemo
1 @DisplayName("PouĹžitĂ doplĹˆkovĂ˝ch parametrĹŻ") 2 public class TestParamDemo 3 { 4 @BeforeAll 5 @DisplayName("PĹ™Ăprava pĹ™ed testy danĂŠ tĹ™Ădy") 6 static void setUpClass(TestInfo info, TestReporter reporter) { 7 print("BeforeAll", info); 8 reporter.publishEntry("BeforeAll", "VytvĂĄĹ™Ăm pĹ™Ăpravek pro celou sadu"); 9 } 10 11 @AfterAll 12 @DisplayName("Ăšklid po testech danĂŠ tĹ™Ădy") 13 static void tearDownClass(TestInfo info, TestReporter reporter) { 14 print("AfterAll", info); 15 reporter.publishEntry("AfterAll", "UklĂzĂm po ukoÄ?nenĂ sady"); 16 } 17 18 TestParamDemo(TestInfo info, TestReporter reporter) { 19 print("Konstruktor", info); 20 reporter.publishEntry("Konstruktor", "VytvĂĄĹ™Ăm instanci"); 21 } 22 23 @BeforeEach 24 @DisplayName("Tvorba pĹ™Ăpravku") 25 void setUp(TestInfo info, TestReporter reporter) { 26 reporter.publishEntry("Before", "VytvĂĄĹ™Ăm pĹ™Ăpravek"); 27 print(" BeforeEach", info); 28 } 29 30 @AfterEach 31 @DisplayName("Ăšklid po testu") 32 void tearDown(TestInfo info, TestReporter reporter) { 33 reporter.publishEntry("After", "UklĂzĂm"); 34 print(" AfterEach", info); 35 } 36 37 @Test 38 @DisplayName("PrvnĂ test đ&#x;˜Šđ&#x;˜Š") 39 void test_1(TestInfo info) { 40 print(" Test", info); 41 } 42 43 @Test 44 @DisplayName("DruhĂ˝ test ☚") 45 void test_2(TestInfo info, TestReporter reporter) { 46 reporter.publishEntry(Map.of("1", "Jedna", "2", "Dva")); 47 reporter.publishEntry("PodruhĂŠ", "DruhĂŠ pouĹžitĂ"); 48 print(" Test", info); 49 } 50 54G_JUnit 5_ZLOM.doc; verze 0.41.7696 – 2018-09-21
Strana 98 z 291 UkĂĄzka elektronickĂŠ knihy, UID: KOS260142