Junit单元测试配置及基本用法

1.引入依赖

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

2.引入基本注解进行调用

@RunWith(SpringRunner.class)
@SpringBootTest
public class Test {

    @Autowired
    private RedisService redisService;
    @Autowired private TQuestionnaireListMapper questionnaireListMapper;

    @org.junit.Test
    public void test() {
        List<TQuestionnaireList> selectList = questionnaireListMapper.list();
        System.out.println(selectList);
    }
}
原文地址:https://www.cnblogs.com/cwshuo/p/15802920.html