In Intellij, how do I create a live template that adds import statements for tests?

You can create a live template for test in IntelliJ 12 like so:

File > Settings... > Live Templates

Adding a template

  1. Add a new template
  2. Set the abbreviation (what you'll type to use this filter)
  3. Type this template (after pressing tab, your cursor will be at $EXPR$ to finish the name of the method, in this case, and $END$ is where the cursor will be after completing the $EXPR$ name (i.e., pressing enter)

    @org.junit.Test
    public void test$EXPR$() {
        $END$
    }
    
  4. Ensure Expand with is set to Tab (or whichever you prefer)
  5. Ensure Shorten Fully Qualified names is enabled (that way @org.junit.Test in the template adds import org.junit.Test; to the top of the file and the method will have just @Test)
  6. Set the Applicable to "in Java: declaration".

Edit: as tieTYT points out, the the import static junit.framework.Assert.* part can be satisfied by creating a new File Template:

JUnit Test File Template

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

import static junit.framework.Assert.*;

#parse("File Header.java")
public class ${NAME}
{

}

The above is just copy-pasted from the Class template, adding the import statement.