在比较大型的项目中,我们需要在开发之前,进行某些模块的先行测试,这就用到了springboot中单元测试工具了
下面我们通过一个小案例,来讲解下如何利用Junit测试工具进行jpa开发的测试
测试代码我们要存放到test包下
这个数据库连接以及jpa的配置
我们利用接口继承jpa实现类
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
以上是maven工程依赖配置
来源:CSDN
作者:BirdMan98
链接:https://blog.csdn.net/weixin_41405524/article/details/104553714