单元测试

maven依赖 pom.xml:

<!-- unit test -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-test</artifactId>
    <version>2.6.6</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <version>2.6.6</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>compile</scope>
</dependency>
<!-- unit test end -->

java类单元测试例子:

@RunWith(SpringRunner.class)
@SpringBootTest
@Service
public class ModTestService extends AbstractBillService/*<ModReceive> implements IModTestService*/ {
    @org.junit.Test
    @Commit //如果有涉及数据提交的,要加上这个注解
    public void test() {
        ....
    }
}
欢迎您的到来,感谢您的支持!

为您推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注