我是jhipster的新手。我想實現一個測試方法來測試從MySQL數據庫中檢索的值。當我嘗試執行「gradlew test」命令時,它將通過說「java.lang.AssertionError:JSON路徑" $。[0] .id」沒有值而使相關測試用例失敗。我已經手動添加了H2 Console數據庫表值。我的測試方法如下。如何測試從jigster中的db中檢索的值
@Test
@Transactional
public void getAllPlayersNS() throws Exception {
// Get all the playersNList
restPlayersNMockMvc.perform(get("/api/players-ns?sort=id,asce"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[0].id").value(1));
}
我哪裏出錯了?
在你的問題中,你需要比這更多的信息。並且請不要將圖像,甚至更糟糕的難以辨認的圖像粘貼到您的問題中。使用格式良好,深思熟慮的文字。 –
謝謝。我已編輯@Tim Biegeleisen –