-1
public String serialize(Map<String, Object> data) throws IOException {
logger.debug("Starting serialisation of json response for thread id [{}] and string [{}]",
Thread.currentThread().getId(), data);
return (data == null) ? "{}" : new ObjectMapper().writeValueAsString(data);
}
創建輸入(地圖)。調用你的方法。檢查它是否返回預期的輸出。這是你可以寫的最簡單的測試。既然你有一個空輸入的特殊情況,添加另一個測試檢查,當輸入爲空時,你會得到預期的輸出。 –
其實我沒有得到任何想法我必須使用這種方法的測試方法 –
然後閱讀:https://github.com/junit-team/junit4/wiki/Getting-started –