{"id":1326,"date":"2015-12-02T17:16:31","date_gmt":"2015-12-02T09:16:31","guid":{"rendered":"http:\/\/www.strongd.net\/?p=1326"},"modified":"2015-12-02T17:21:15","modified_gmt":"2015-12-02T09:21:15","slug":"how-to-skip-maven-unit-test","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=1326","title":{"rendered":"How to skip Maven unit test"},"content":{"rendered":"<p>By default, when building project, Maven will run the entire unit tests automatically. If any of unit test is failed, it will force Maven to abort the building process.<\/p>\n<pre class=\" language-bash\"><code class=\" language-bash\">$ mvn <span class=\"token function\">install<\/span>\r\n$ mvn package \r\n<\/code><\/pre>\n<p>In real life, you may \u201c<strong>STILL<\/strong>\u201d need to build your project even some of the cases are failed.<\/p>\n<h2>Skip Unit Test<\/h2>\n<p>To skip the entire unit test, uses argument \u201c<code>-Dmaven.test.skip=true<\/code>\u201c.<\/p>\n<pre class=\" language-bash\"><code class=\" language-bash\">$ mvn <span class=\"token function\">install<\/span> <span class=\"token operator\">-<\/span>Dmaven<span class=\"token punctuation\">.<\/span><span class=\"token function\">test<\/span><span class=\"token punctuation\">.<\/span>skip<span class=\"token operator\">=<\/span><span class=\"token boolean\">true<\/span>\r\n$ mvn package <span class=\"token operator\">-<\/span>Dmaven<span class=\"token punctuation\">.<\/span><span class=\"token function\">test<\/span><span class=\"token punctuation\">.<\/span>skip<span class=\"token operator\">=<\/span><span class=\"token boolean\">true<\/span>\r\n<\/code><\/pre>\n<p>Or define <code>skipTests<\/code> in <code>maven-surefire-plugin<\/code>.<\/p>\n<div class=\"filename\">pom.xml<\/div>\n<pre class=\" language-markup\"><code class=\" language-markup\">   <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>plugin<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n\t<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>org.apache.maven.plugins<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n\t<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>maven-surefire-plugin<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n\t<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>version<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>2.12.4<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>version<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n\t<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>configuration<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n\t\t<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>skipTests<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>true<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>skipTests<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n\t<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>configuration<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>plugin<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\r\n<\/code><\/pre>\n<p>Now, build the project again, the entire unit tests will be ignored.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, when building project, Maven will run the entire unit tests automatically. If any of unit test is failed, it will force Maven to abort the building process. $ mvn install $ mvn package In real life, you may \u201cSTILL\u201d need to build your project even some of the cases are failed. Skip Unit &hellip; <a href=\"https:\/\/www.strongd.net\/?p=1326\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to skip Maven unit test<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[83],"class_list":["post-1326","post","type-post","status-publish","format-standard","hentry","category-java","tag-maven"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1326"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1326\/revisions"}],"predecessor-version":[{"id":1327,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1326\/revisions\/1327"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}