Skip to content

Instantly share code, notes, and snippets.

@yusufsoysal
Created March 18, 2017 16:36
Show Gist options
  • Save yusufsoysal/47442b5ed1131c88bfff559820836a4e to your computer and use it in GitHub Desktop.
Save yusufsoysal/47442b5ed1131c88bfff559820836a4e to your computer and use it in GitHub Desktop.
Intellij IDEA JUnit4 Test Class Template
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
#parse("File Header.java")
#set($lastIndex = $CLASS_NAME.lastIndexOf(".") + 1)
#set($onlyClassName = $CLASS_NAME.substring($lastIndex))
#set($Controller_name = $onlyClassName.substring(0,1).toLowerCase() + $onlyClassName.substring(1))
@RunWith(MockitoJUnitRunner.class)
public class ${NAME} {
@InjectMocks
private ${CLASS_NAME} ${Controller_name};
${BODY}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment