【发布时间】:2021-05-13 07:47:34
【问题描述】:
我目前正在研究微服务,这个项目基本上是一个库,它没有主要功能。我正在为这个库编写单元测试用例,但我找不到 @ SpringBoot 配置。如果没有main函数,我们不能执行单元测试用例吗?
库中唯一的文件
class OnlyFile {
void validate(){
}
}
测试
@SpringBootTest
class MyTest {
@Test
void testIt(){
//
//
}
}
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.3.3.RELEASE</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
【问题讨论】:
标签: java spring spring-boot junit