栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Idea + Junit Generator 一件生成测试类模板

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Idea + Junit Generator 一件生成测试类模板

插件自带的模板感觉不是很好用,于是自己研究了一个
 

##
#macro (firsyCharToUpperCase $strIn)$strIn.valueOf($strIn.charAt(0)).toUpperCase()$strIn.substring(1)#end
#macro (firsyCharToLowerCase $strIn)$strIn.valueOf($strIn.charAt(0)).toLowerCase()$strIn.substring(1)#end
## Iterate through the list and generate testcase for every entry.
#foreach ($entry in $entryList)
#set($testClass="${entry.className}Test")
#set($testObj="#firsyCharToLowerCase(${entry.className})")
##
package $entry.packageName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.fastjson.JSONObject;


@SpringBootTest
@RunWith(SpringRunner.class)
public class $testClass {

    @Autowired
    private ${entry.className} $testObj;

#foreach($method in $entry.methodList)
    @Test
    public void test#firsyCharToUpperCase(${method.name})() {
        // System.out.println(JSONObject.toJSONString($testObj.${method.name}()));
    }
#end
}
#end
分享请注明来源

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/826291.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号