{"id":878,"date":"2011-04-29T11:23:00","date_gmt":"2011-04-29T09:23:00","guid":{"rendered":""},"modified":"2022-07-26T13:07:04","modified_gmt":"2022-07-26T11:07:04","slug":"using-eclipse-snippets-for-faster-junit-test-creation-with-mockito","status":"publish","type":"post","link":"https:\/\/touk.pl\/blog\/2011\/04\/29\/using-eclipse-snippets-for-faster-junit-test-creation-with-mockito\/","title":{"rendered":"<!--:en-->Using Eclipse snippets for faster JUnit test creation (with Mockito!)<!--:-->"},"content":{"rendered":"<p><!--:en-->I&#8217;m using this snippet to create a template of new unit test method supporting BDD\u00a0<\/p>\n<p><a href=\"http:\/\/mockito.org\">mockito\u00a0<\/a>tests. This is a good example for adding static imports to a class from snippets.<\/p>\n<pre>@${testType:newType(org.junit.Test)}\npublic void should${testname}() {\n${staticImport:importStatic('org.mockito.BDDMockito.*', 'org.mockito.Matchers.*', 'org.mockito.Mockito.*', 'org.junit.Assert.*')}\/\/ given<\/pre>\n<p>\/\/ when ${cursor} \/\/ then } The result is astonishing ;)<\/p>\n<pre>import static org.mockito.BDDMockito.*;\nimport static org.mockito.Matchers.*;\nimport static org.mockito.Mockito.*;\nimport static org.junit.Assert.*;<\/pre>\n<p>(&#8230;) @Test public void shouldTestSomething() { \/\/ given \/\/ when CURSOR_LANDS_HERE \/\/ then }<\/p>\n<div>\n  <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/tracker\/3430508731490960624-3860500732272980998?l=blog.bartekzdanowski.pl\" alt=\"\" width=\"1\" height=\"1\" \/>\n<\/div>\n<p><!--:--><\/p>\n","protected":false},"excerpt":{"rendered":"I&#8217;m using this snippet to create a template of new unit test method supporting BDD mockito tests. This is a good example for adding static imports to a class from snippets.@${testType:newType(org.junit.Test)}public void should${testname}() { ${staticIm&#8230;I&#8217;m using this snippet to create a template of new unit test method supporting BDD mockito tests. This is a good example for adding static imports to a class from snippets.@${testType:newType(org.junit.Test)}public void should${testname}() { ${staticIm&#8230;\n","protected":false},"author":22,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[30],"class_list":{"0":"post-878","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-development-design","7":"tag-testing"},"_links":{"self":[{"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/comments?post=878"}],"version-history":[{"count":14,"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/posts\/878\/revisions"}],"predecessor-version":[{"id":14363,"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/posts\/878\/revisions\/14363"}],"wp:attachment":[{"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/media?parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/categories?post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/touk.pl\/blog\/wp-json\/wp\/v2\/tags?post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}