/www/wwwroot/blog.drearry.com/usr/plugins/AMP/templates/MIPpage.php on line 33
">

SpringBoot 单元测试

2023-06-26T18:19:00

使用 SpringInitalizr 方式搭建的 SpringBoot 项目,会自动加入 spring-boot-starter-test 测试依赖启动器,无需开发者手动添加

编写测试类

package com.example.demo1;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class Demo1ApplicationTests {

@Autowired
private HelloWorld HelloWorld;

@Test
public void setHelloControllerTest() {
    String hello = HelloWorld.Hello();
    System.out.println(hello);
}

}
点击运行,开始测试

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »