springboot的测试类
引入jar包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<!--test表明只能在test包下才可以用的jar,在非test包下不可用-->
<scope>test</scope>
</dependency>
编写测试类
@RunWith(SpringRunner.class)
@SpringBootTest(classes = NtWebdcApplication.class)
public class TestBean {
@Autowired
TestUuidService testUuidService;
@Test
public void testSelectAllProvinces() {
List<TestUuid> list = new ArrayList<>();
for (int i = 0; i < 20; i++) {
TestUuid testUuid = new TestUuid();
testUuid.setName("test" + i);
list.add(testUuid);
}
testUuidService.saveBatch(list);
}
}