IED配置
1、下载插件 JUnitGenerator
Output Path 配置内容=》 ${SOURCEPATH}/../../test/java/${PACKAGE}/${FILENAME}
2、配置模板
########################################################################################
##
## Available variables:
## $entryList.methodList - List of method composites
## $entryList.privateMethodList - List of private method composites
## $entryList.fieldList - ArrayList of class scope field names
## $entryList.className - class name
## $entryList.packageName - package name
## $today - Todays date in MM/dd/yyyy format
##
## MethodComposite variables:
## $method.name - Method Name
## $method.signature - Full method signature in String form
## $method.reflectionCode - list of strings representing commented out reflection code to access method (Private Methods)
## $method.paramNames - List of Strings representing the method's parameters' names
## $method.paramClasses - List of Strings representing the method's parameters' classes
##
## You can configure the output class name using "testClass" variable below.
## Here are some examples:
## Test${entry.ClassName} - will produce TestSomeClass
## ${entry.className}Test - will produce SomeClassTest
##
########################################################################################
##
#macro (cap $strIn)$strIn.valueOf($strIn.charAt(0)).toUpperCase()$strIn.substring(1)#end
## Iterate through the list and generate testcase for every entry.
#foreach ($entry in $entryList)
#set( $testClass="${entry.className}Test")
##
package $entry.packageName;
import org.junit.Test;
public class $testClass extends BaseTest {
#foreach($method in $entry.methodList)
/**
*
* Method: $method.signature
*
*/
@Test
public void test#cap(${method.name})() throws Exception {
//TODO: Test goes here...
}
#end
}
#end
使用
Ctrl+Shift+t
intellij-javadocs-4.0.1.xml配置
<?xml version="1.0" encoding="UTF-8"?> UPDATE false true TYPE METHOD FIELD PUBLIC PROTECTED DEFAULT PRIVATE ^.*(public|protected|private)*.+interface\s+\w+.* /**\n * 描述该接口实现的功能\n <#if element.typeParameters?has_content></#if><#list element.typeParameters as typeParameter> * @param <${typeParameter.name}> 泛型参数\n </#list> *\n * @since v1.0\n * @author wangtao\n * @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n */ ^.*(public|protected|private)*.+enum\s+\w+.* /**\n * 描述该枚举的用途\n *\n * @since v1.0\n * @author wangtao\n * @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n */ ^.*(public|protected|private)*.+class\s+\w+.* /**\n * 描述该类实现的功能\n <#if element.typeParameters?has_content></#if><#list element.typeParameters as typeParameter> * @param <${typeParameter.name}> 描述此泛型参数\n </#list> *\n * @since v1.0\n * @author wangtao\n * @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n */ .+ /**\n * 描述该类实现的功能 *\n * @since v1.0\n * @author wangtao\n * @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n */