14 April 2011

Getting that Skeleton test up

When creating a new unit test file, getting the import statics right with Hamcrest is 30 seconds of hassle, every time.

Here is the typical unit test start-up I prefer:
@Test
public void skeletonTest() {
assertThat(true, is(equalTo(true)));
}
Here is a eclipse template, which may solve this. But may also not, as I tend to forget little tricks like these. Time will tell if I've been able to incorporate this my reflexes.

So, get the template in, make the new junit test file, type skeltest and press ctrl+space.
























The template:
${imp:import(org.junit.Test)}
${imps:importStatic(
org.hamcrest.Matchers.equalTo,
org.hamcrest.Matchers.is,
org.junit.Assert.assertThat)}
@Test
public void skeletonTest() {
assertThat(true, is(equalTo(true)));
}

No comments:

Post a Comment