1、下载JUnitGenerator V2.0插件
下载地址:https://plugins.jetbrains.com/plugin/3064-junitgenerator-v2-0
2、在IDEA中安装 file>setting,选择下载的jar包安装后重启IDEA即可
3、设置路径:${SOURCEPATH}/../../test/java/${PACKAGE}/${FILENAME}
4、在maven项目pom.xml中添加依赖
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
5、在类或方法上按alt+enter生成类