Junit4模板

Posted zenan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Junit4模板相关的知识,希望对你有一定的参考价值。

模板

MallApplicationTests

import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class MallApplicationTests {
}

其余测试类继承上述主类即可

import org.junit.Test;

public class CategoryMapperTest extends MallApplicationTests {

    @Resource
    private CategoryMapper categoryMapper;

    @Test
    public void countByExample() {
        CategoryExample categoryExample = new CategoryExample();
        categoryExample.or().andParentIdEqualTo(0);
        long count = categoryMapper.countByExample(categoryExample);
        System.out.println(count);
    }
}

以上是关于Junit4模板的主要内容,如果未能解决你的问题,请参考以下文章