SpringTest

[toc]

配置

pom文件

相关

<!-- 单元测试 -->
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>${junit.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>${junit.version}</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.hamcrest</groupId>
  <artifactId>hamcrest-core</artifactId>
  <version>${hamcrest.core.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.mockito</groupId>
  <artifactId>mockito-core</artifactId>
  <version>${mockito.core.version}</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-test</artifactId>
  <version>${spring.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
<dependency>
  <groupId>com.jayway.jsonpath</groupId>
  <artifactId>json-path</artifactId>
  <version>${json-path.version}</version>
</dependency>    <!-- ./单元测试 -->

全部

applicationContext.xml

springmvc.xml

SqlMapConfig.xml

示例

常用

对返回Json数据进行验证

Java代码

相关

全部

测试类

服务实现类

配置及依赖

相较于上述测试,需要的额外以来有:

  • com.jayway.jsonpath

pom.xml相关配置

pom.xml全部配置

最后更新于

这有帮助吗?