Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JUnit 5の拡張機能を完全にマスターした

irof
September 19, 2019

JUnit 5の拡張機能を完全にマスターした

2019-09-19T19:00 関ジャバ'19 9月度のセッション資料です。
https://kanjava.connpass.com/event/141792/

irof

September 19, 2019
Tweet

More Decks by irof

Other Decks in Technology

Transcript

  1. όʔδϣϯΛோΊΔ     w ฒྻ࣮ߦ w ඪ४ग़ྗͷΩϟϓνϟ w

    ಈతςετ w !5FNQ%JS w 5FTU8BUDIFS w ج൫։ൃऀ޲͚"1*ॆ࣮ w !5JNFPVU w ֦ுϙΠϯτͭ w NPEVMFରԠ ϚΠΫϩόʔδϣϯ͸όάϑΟοΫεɻ
  2. 5JNFPVU&YUFOTJPO @Timeout(value = 3, unit = TimeUnit.MILLISECONDS) public class SampleTimeout

    { @Test void test() throws Exception { TimeUnit.MILLISECONDS.sleep(5); } } w λΠϜΞ΢τʢ໓ଟʹ࢖Θͳ͍ʣ
  3. 5FNQ%JSFDUPSZ public class SampleTempDir { @TempDir Path tempDirPath; @Test void

    test() { System.out.println(tempDirPath); } } w !5FNQ%JSͳϑΟʔϧυ΍ύϥϝʔλ͕͋ͬͨΒ04ͷUFNQEJSʹσΟϨΫτϦΛ࡞ͬͯ 1BUIΛηοτͯ͘͠ΕΔɻ w KVOJUQJPOFFSʹ͋ͬͨͷ͕ຊՈʹऔΓࠐ·Εͨɻʢ·ͩ&91&3*.&/5"-͚ͩͲʣ
  4. 4QSJOH&YUFOTJPO // Spring @ExtendWith(SpringExtension.class) public class SampleSpringTest { // Spring

    Boot @SpringBootTest public class SampleSpringBootTest { w 4QSJOH࢖͏ͳΒɻ w 4QSJOH#PPU5FTU͸ϝλΞϊςʔγϣϯͷྫʹ΋ͳΔɻ
  5. ྫ֎ϋϯυϥΛ࣮૷ class MahouExtension implements TestExecutionExceptionHandler { @Override public void handleTestExecutionException(

    ExtensionContext context, Throwable throwable) { } } w Կ΋͠ͳ͖ΌѲΓͭͿ͢͜ͱʹͳΔɻ