I’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}() {
${staticImport:importStatic('org.mockito.BDDMockito.*', 'org.mockito.Matchers.*', 'org.mockito.Mockito.*', 'org.junit.Assert.*')}// given
// when ${cursor} // then } The result is astonishing ;)
import static org.mockito.BDDMockito.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import static org.junit.Assert.*;
(…) @Test public void shouldTestSomething() { // given // when CURSOR_LANDS_HERE // then }
Couple of years ago I wasn't a big fan of unit testing. It was obvious to me that well prepared unit tests are crucial though. I didn't known why exactly crucial yet then. I just felt they are important. My disliking to write automation tests was mostly related to the effort necessary to prepare them. Also a spaghetti code was easily spotted in test sources.
