2

私は失敗したテスト ケースを収集するために、次のようなコードで ErrorCollector ルールを使用しています。

@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());
    } 

}

したがって、私の問題は、すべてのエラーを収集した後、すべてのエラーを出力できる方法と、テストケースを作成する方法がありますか?

4

1 に答える 1