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

猜你喜欢

转载自www.cnblogs.com/zenan/p/12056964.html