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