{"id":93,"date":"2018-06-24T20:03:28","date_gmt":"2018-06-24T20:03:28","guid":{"rendered":"https:\/\/blog.adonlon.org\/?p=93"},"modified":"2019-03-24T12:25:52","modified_gmt":"2019-03-24T12:25:52","slug":"junit5-migration","status":"publish","type":"post","link":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/","title":{"rendered":"JUnit5 Migration"},"content":{"rendered":"<p>some learnings related to migrating to JUnit5.<\/p>\n<ul>\n<li>JUnit5 has different dependencies, in terms of maven \/ gradle coordinates. We&#8217;re not just talking about bumping a version number. Importantly, the project name &#8216;Juniper&#8217; is one which you&#8217;ll come across regularly with JUnit5.<\/li>\n<li>JUnit5 requires the maven surefire plugin (and similar for gradle) to use a different test runner from the one packaged as standard. This is a configuration change.<\/li>\n<li>There&#8217;s a JUnit4 compatibility layer to allow seamless migration without code change.<\/li>\n<li>New-style JUnit5 test can coexist with old-style JUnit4 (vintage) tests in the same codebase.<\/li>\n<li>Some new IDEA warnings relate specifically to some things about how the new JUnit5 functionality can reduce the amount of boilerplate in your test code.<\/li>\n<li>The new JUnit5 API exists within a new package &#8211; org.junit.juniper.api. Any JUnit5 test should only pull in things from under that package. The old &#8216;junit.Test&#8217; and &#8216;org.junit.Test&#8217; annotations only exist for backwards compatibility with JUnit4.<\/li>\n<li>There are some simple 1-1 differences between old-style and new-style uses.\n<ul>\n<li>@Test is in the new package.<\/li>\n<li>@Before and @After become @BeforeEach and @AfterEach (+ package change) respectively<\/li>\n<li>@BeforeClass and @AfterClass become @BeforeAll and @AfterAll respectively<\/li>\n<\/ul>\n<\/li>\n<li>After that there are some more complex changes required around Rules\n<ul>\n<li>@Rule is replaced by @RegisterExtension. However, JUnit4 Rules cannot *simply* be repurposed as JUnit5 extensions (because they operate on a different API).<\/li>\n<li>It&#8217;s *usually* possible to convert an &#8216;ExternalResource&#8217; @Rule into an extension by implementing the appropriate interfaces (e.g. BeforeEachCallback, AfterEachCallback)<\/li>\n<\/ul>\n<\/li>\n<li>With a JUnit5 test methods no longer need to be public.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>some learnings related to migrating to JUnit5. JUnit5 has different dependencies, in terms of maven \/ gradle coordinates. We&#8217;re not just talking about bumping a version number. Importantly, the project name &#8216;Juniper&#8217; is one which you&#8217;ll come across regularly with JUnit5. JUnit5 requires the maven surefire plugin (and similar for gradle) to use a different [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-93","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JUnit5 Migration - Pragmatic Software Engineering<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit5 Migration - Pragmatic Software Engineering\" \/>\n<meta property=\"og:description\" content=\"some learnings related to migrating to JUnit5. JUnit5 has different dependencies, in terms of maven \/ gradle coordinates. We&#8217;re not just talking about bumping a version number. Importantly, the project name &#8216;Juniper&#8217; is one which you&#8217;ll come across regularly with JUnit5. JUnit5 requires the maven surefire plugin (and similar for gradle) to use a different [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/\" \/>\n<meta property=\"og:site_name\" content=\"Pragmatic Software Engineering\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-24T20:03:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-24T12:25:52+00:00\" \/>\n<meta name=\"author\" content=\"alastair\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"alastair\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/\"},\"author\":{\"name\":\"alastair\",\"@id\":\"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1\"},\"headline\":\"JUnit5 Migration\",\"datePublished\":\"2018-06-24T20:03:28+00:00\",\"dateModified\":\"2019-03-24T12:25:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/\"},\"wordCount\":265,\"publisher\":{\"@id\":\"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1\"},\"articleSection\":[\"Uncategorized\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/\",\"url\":\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/\",\"name\":\"JUnit5 Migration - Pragmatic Software Engineering\",\"isPartOf\":{\"@id\":\"https:\/\/blog.adonlon.org\/#website\"},\"datePublished\":\"2018-06-24T20:03:28+00:00\",\"dateModified\":\"2019-03-24T12:25:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.adonlon.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JUnit5 Migration\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.adonlon.org\/#website\",\"url\":\"https:\/\/blog.adonlon.org\/\",\"name\":\"Pragmatic Software Engineering\",\"description\":\"Random thoughts and insights on software engineering\",\"publisher\":{\"@id\":\"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.adonlon.org\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1\",\"name\":\"alastair\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/blog.adonlon.org\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cf9abf1220f449fccd0f6795d12b05cb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cf9abf1220f449fccd0f6795d12b05cb?s=96&d=mm&r=g\",\"caption\":\"alastair\"},\"logo\":{\"@id\":\"https:\/\/blog.adonlon.org\/#\/schema\/person\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JUnit5 Migration - Pragmatic Software Engineering","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/","og_locale":"en_GB","og_type":"article","og_title":"JUnit5 Migration - Pragmatic Software Engineering","og_description":"some learnings related to migrating to JUnit5. JUnit5 has different dependencies, in terms of maven \/ gradle coordinates. We&#8217;re not just talking about bumping a version number. Importantly, the project name &#8216;Juniper&#8217; is one which you&#8217;ll come across regularly with JUnit5. JUnit5 requires the maven surefire plugin (and similar for gradle) to use a different [&hellip;]","og_url":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/","og_site_name":"Pragmatic Software Engineering","article_published_time":"2018-06-24T20:03:28+00:00","article_modified_time":"2019-03-24T12:25:52+00:00","author":"alastair","twitter_card":"summary_large_image","twitter_misc":{"Written by":"alastair","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/#article","isPartOf":{"@id":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/"},"author":{"name":"alastair","@id":"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1"},"headline":"JUnit5 Migration","datePublished":"2018-06-24T20:03:28+00:00","dateModified":"2019-03-24T12:25:52+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/"},"wordCount":265,"publisher":{"@id":"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1"},"articleSection":["Uncategorized"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/","url":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/","name":"JUnit5 Migration - Pragmatic Software Engineering","isPartOf":{"@id":"https:\/\/blog.adonlon.org\/#website"},"datePublished":"2018-06-24T20:03:28+00:00","dateModified":"2019-03-24T12:25:52+00:00","breadcrumb":{"@id":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.adonlon.org\/index.php\/2018\/06\/24\/junit5-migration\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.adonlon.org\/"},{"@type":"ListItem","position":2,"name":"JUnit5 Migration"}]},{"@type":"WebSite","@id":"https:\/\/blog.adonlon.org\/#website","url":"https:\/\/blog.adonlon.org\/","name":"Pragmatic Software Engineering","description":"Random thoughts and insights on software engineering","publisher":{"@id":"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.adonlon.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/blog.adonlon.org\/#\/schema\/person\/4c5a1b2463425db9814bf8540f8954c1","name":"alastair","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/blog.adonlon.org\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cf9abf1220f449fccd0f6795d12b05cb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf9abf1220f449fccd0f6795d12b05cb?s=96&d=mm&r=g","caption":"alastair"},"logo":{"@id":"https:\/\/blog.adonlon.org\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/comments?post=93"}],"version-history":[{"count":0,"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/posts\/93\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/categories?post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.adonlon.org\/index.php\/wp-json\/wp\/v2\/tags?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}