添加依赖
dependencies {
compile('org.springframework.boot:spring-boot-starter-webflux')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile("org.junit.jupiter:junit-jupiter-api")
testRuntime("org.junit.jupiter:junit-jupiter-engine")
}
创建测试类
@DataJpaTest
// 添加下面这个注解就可以运行测试了
@ExtendWith(SpringExtension.class)
class Junit5Test {
@Autowired
TestEntityManager entityManager;
@Test
void runTest() {
entityManager.persist(new User(100));
}
}