I wrote this test method in Scala to test a REST service.
@Test def whenRequestProductInfo() {
// When Request Product Info
forAll { (productId: Int) =>
val result = mockMvc().perform(get(s"/products/$productId")
.accept(MediaType.parseMediaType(APPLICATION_JSON_CHARSET_UTF_8)))
.andExpect(status.isOk)
.andExpect(content.contentType(APPLICATION_JSON_CHARSET_UTF_8))
.andReturn;
val productInfo = mapper.readValue(result.getResponse.getContentAsString, classOf[ProductInfo])
// At least one is not null
// assert(productInfo.getInventoryInfo != null)
}
}
But I want to test that at least one productInfo.getInventoryInfo is not null instead of every productInfo.getInventoryInfo is not null.
Aucun commentaire:
Enregistrer un commentaire