美文网首页
Spring boot Junit Test搭建注意事项

Spring boot Junit Test搭建注意事项

作者: 暗夜行者 | 来源:发表于2020-03-17 23:03 被阅读0次

import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@TestPropertySource(
locations = "classpath:application.yaml")
//note: name must be application.yaml or application.properties
//no need to add public ,or it will get initialize error because we use org.junit.jupiter.api.Test

class PrepositoryTest {
}

相关文章

网友评论

      本文标题:Spring boot Junit Test搭建注意事项

      本文链接:https://www.haomeiwen.com/subject/zsxofhtx.html