Zil*_* av 5 java maven rest-assured spring-boot json-schema-validator
我正在使用Spring Boot和REST Assured来测试REST API.我正在尝试使用JSON模式验证的示例,但它会抛出此错误:
java.lang.IllegalArgumentException: Schema to use cannot be null
Run Code Online (Sandbox Code Playgroud)
根据文档,架构应位于类路径中.我的示例架构位于那里.这是我的项目结构和示例模式位置:
这是我的代码.没有架构验证它工作正常.
given().
contentType("application/json").
when().
get("http://myExample/users").
then().
assertThat().body(matchesJsonSchemaInClasspath("example_schema.json"));
Run Code Online (Sandbox Code Playgroud)
您的模式文件位于rest.resource包中,但在调用时您没有提到过matchesJsonSchemaInClasspath.您需要将文件移动到类路径的根目录(src/test/resources例如,将其放入),或者更改您传入的字符串matchesJsonSchemaInClasspath.
| 归档时间: |
|
| 查看次数: |
4963 次 |
| 最近记录: |