Skip to content

Instantly share code, notes, and snippets.

@hstaudacher
Created March 20, 2012 11:20
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hstaudacher/2134193 to your computer and use it in GitHub Desktop.
Save hstaudacher/2134193 to your computer and use it in GitHub Desktop.
JUnit4 Templates for Eclipse
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="java" deleted="false" description="" enabled="true" name="setup">${:import(org.junit.Before)}
@Before
public void setUp() {
${cursor}
}</template><template autoinsert="true" context="java" deleted="false" description="" enabled="true" name="teardown">${:import(org.junit.After)}
@After
public void tearDown() {
${cursor}
}</template><template autoinsert="false" context="java-members" deleted="false" description="test method" enabled="true" id="org.eclipse.jdt.ui.templates.test" name="test">${:import(org.junit.Test)}
@Test
public void test${name}() {
${cursor}
}</template></templates>
@Sevyls
Copy link

Sevyls commented Aug 13, 2015

Steps to import:

  1. Eclipse: Window->Preferences
  2. Java->Editor->Templates
  3. Import...
  4. Choose file
  5. check for template names "setup", "teardown" and "test" (there is no prompt or message for successfully imported data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment