我在admin模块的pom引入:
<!--测试相关--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test</artifactId> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>5.3.27</version> <scope>compile</scope> </dependency>
然后编写测试类,一直报错,后来网上查砍别人的做法,还要再测试类上面加注解:
@RunWith(SpringRunner.class) @SpringBootTest(classes = RuoYiApplication.class)
个人理解,第二句的原因是若依的启动类名字比较特殊,第一句暂时不太清除