Springboot创建测试类:
1、导包
<!--测试--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency>
2、Shift + Alt + T 创建测试类
选择你的包,然后点击OK
3、在测试类上添加注解
@RunWith(SpringRunner.class)
@SpringBootTest(classes = 你的启动类.class)
4、测试
@RunWith(SpringRunner.class)
@SpringBootTest(classes = App.class)
class AnimalMapperTest {
@Autowired
private AnimalMapper animalMapper;
@Test
public void list(){
QueryWrapper<Animal> wrapper = new QueryWrapper<>();
animalMapper.selectList(wrapper).forEach(System.out::println);
}
}