SpringBoot快捷键测试类

SpringBoot快捷键测试类,第1张

导入junit依赖

     <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
          <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

在测试类后面alt+ins

选择Junit4和要Test的类

添加注解(classes中要写启动类名字)

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class)
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class)
public class UserServiceTest {
    @Autowired
    private UserService userService;

    @Test
    public void userRegist() {
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/791265.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-05
下一篇2022-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存