Junit单元测试配置及基本用法(JUnit unit test configuration and basic usage)

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);
    }
}
————————

1. Introduce dependency

        <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. Introduce basic annotation for calling

@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);
    }
}