Junit学习笔记

1.JUnit - 基本用法

使用原因:测试就是检验实际输出是否符合预期。只有经过验证的代码才能上生产。通过单元测试,可以极大的减少人工黑盒测试的劳动量。

Junit是一个单元测试框架。主要就用来完成单元测试的基本功能。各个IDE也都提供了很好的支撑。在Maven中也有对应的流程体现。

基本上已经是事实的标准了。



2.SpringBoot使用Juint


依赖:

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-test</artifactId>

    <scope>test</scope>

</dependency>




测试类:

import lombok.extern.slf4j.Slf4j;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.boot.test.context.SpringBootTest;

import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)

@SpringBootTest//(classes = WebBootApplication.class)

@Slf4j

public class WebBootApplicationTests {

@Autowired

    IntervieweeServiceintervieweeService;

@Test

    public void queryIntervieweeInfoTest(){

Account account =new Account();

account.setTel("");

account.setMail("1328912651@qq.com");

Interviewee interviewee =intervieweeService.queryIntervieweeInfo(account);

log.info(interviewee.toString());

}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容