I have been using ErrorCollector Rule for collecting the failed test cases with a code that looks something like this :
@Rule
ErrorCollector collector = new ErrorCollector();
Map<X, Y> inputOutputMap = new HashMap<X,Y>();
inputOutputMap.add(new X("Input"), new Y("Output"));
//Mocking service layers and returning expected outputs.
for(Entry<X,Y> entry : inputOutputMap.entrySet()){
String url = "/do/something"
Gson gson = new Gson();
String json = gson.toJson();
try{
this.mockMvc.perform(get(url)
.contentType(MediaType.APPLICATION_JSON)
.content(json)).andExpect(status().isInternalServerError());
} catch(Exception e) {
collector.checkThat(e.getMessage, entry.getValue().getMessage());
}
}
So my problem is after collecting all the errors is there a way I can print all the errors also the way I write the test cases is this a write way - iterating a map and checking for output for respective input?