{"id":4564,"date":"2014-03-30T13:32:29","date_gmt":"2014-03-30T13:32:29","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/org-springframework-util-assert-shows-in-my-surefire-reports-as-an-error-when-in-fact-it-should-be-a-failure-collection-of-common-programming-errors\/"},"modified":"2014-03-30T13:32:29","modified_gmt":"2014-03-30T13:32:29","slug":"org-springframework-util-assert-shows-in-my-surefire-reports-as-an-error-when-in-fact-it-should-be-a-failure-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/org-springframework-util-assert-shows-in-my-surefire-reports-as-an-error-when-in-fact-it-should-be-a-failure-collection-of-common-programming-errors\/","title":{"rendered":"org.springframework.util.Assert shows in my surefire reports as an error, when in fact it should be a failure-Collection of common programming errors"},"content":{"rendered":"<p>You are using the wrong <code>Assert<\/code> class in your unit tests:<\/p>\n<ul>\n<li>\n<p>the <code>org.junit.Assert<\/code> class is for use in unit tests<\/p>\n<\/li>\n<li>\n<p>the <code>org.springframework.util.Assert<\/code> class is for use in runtime code.<\/p>\n<\/li>\n<\/ul>\n<p>And the practical difference is that they throw different exceptions.<\/p>\n<p>If your unit test is testing whether (say) your bean&#8217;s <code>afterPropertiesSet()<\/code> method is calling <code>org.springframework.util.Assert<\/code> correctly, then this is not a simple JUnit style assertion. Rather, it is a test that <code>IllegalArgumentException<\/code> is being thrown, and should be tested in the same way that you would test for (say) <code>IOException<\/code> being thrown at the appropriate point.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You are using the wrong Assert class in your unit tests: the org.junit.Assert class is for use in unit tests the org.springframework.util.Assert class is for use in runtime code. And the practical difference is that they throw different exceptions. If your unit test is testing whether (say) your bean&#8217;s afterPropertiesSet() method is calling org.springframework.util.Assert correctly, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4564","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4564"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4564\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}