Load JSON with JUnit 4 extension
Thu Aug 27 2020 11:23:14 GMT+0000 (UTC)
Posted by
@hosuaby
#java
class MyTestClass {
/* Parse JSON with Jackson */
@Rule
public JsonResource<Map<String, Object>> jsonAsMap = givenResource()
.json("/com/adelean/junit/jupiter/sponge-bob.json")
.parseWith(new ObjectMapper());
/* Parse JSON lines with Gson */
@Rule
public JsonLinesResource<Collection<Log>> logsAsCollection = givenResource()
.jsonLines("/com/adelean/junit/jupiter/logs.jsonl")
.parseWith(new Gson());
}
content_copy Copy
Comments