JUnit 5 (Ukázka, strana 99)

Page 1

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


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
JUnit 5 (Ukázka, strana 99) by Kosmas-CZ - Issuu