本文整理匯總了Java中org.junit.jupiter.api.Assertions.assertAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Assertions.assertAll方法的具體用法?Java Assertions.assertAll怎麽用?Java Assertions.assertAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.jupiter.api.Assertions
的用法示例。
在下文中一共展示了Assertions.assertAll方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateGreeting
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
@DisplayName("Updating a greeting should work")
void updateGreeting() {
// Given we have a greeting already saved
GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
Assumptions.assumeTrue(savedGreeting != null);
// When we update it
savedGreeting.setMessage("Updated message");
service.updateGreetingWithId(savedGreeting.getId(), savedGreeting);
// Then it should be updated
Optional<GreetingDto> updatedGreetingOptional = service.findGreetingById(savedGreeting.getId());
Assertions.assertAll("Updating a greeting by id should work",
() -> assertTrue(updatedGreetingOptional.isPresent(), "Could not find greeting by id"),
() -> assertEquals(savedGreeting.getId(), updatedGreetingOptional.get().getId(), "Updated greeting has invalid id"),
() -> assertEquals("Updated message", updatedGreetingOptional.get().getMessage(), "Updated greeting has different message from the expected updated one"));
}
示例2: saveGreeting
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
@DisplayName("Saving a greeting should work")
void saveGreeting() {
GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
Assertions.assertAll("Saving greetings should work",
() -> assertNotNull(savedGreeting, "Greeting creation failed"),
() -> assertNotNull(savedGreeting.getId(), "Greeting is not saved"),
() -> assertEquals("We come in peace!", savedGreeting.getMessage(), "Invalid greeting message"));
}
示例3: findGreetingById
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
@DisplayName("Retrieving a greeting by id should work")
void findGreetingById() {
// Given we have a greeting already saved
GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
Assumptions.assumeTrue(savedGreeting != null);
// When we try to retrieve it
Optional<GreetingDto> greetingByIdOptional = service.findGreetingById(savedGreeting.getId());
// Then it should be there
Assertions.assertAll("Retrieving a greeting by id should work",
() -> assertTrue(greetingByIdOptional.isPresent(), "Could not find greeting by id"),
() -> assertEquals(savedGreeting.getId(), greetingByIdOptional.get().getId(), "Retrieved greeting has invalid id"),
() -> assertEquals(savedGreeting.getMessage(), greetingByIdOptional.get().getMessage(), "Retrieved greeting has different message from the saved one"));
}
示例4: deleteGreetingById
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
@DisplayName("Removing a greeting by id should work")
void deleteGreetingById() {
// Given we have a greeting already saved
GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
Assumptions.assumeTrue(savedGreeting != null);
// When we delete it
service.deleteGreetingById(savedGreeting.getId());
// Then it should be removed
Optional<GreetingDto> deletedGreetingOptional = service.findGreetingById(savedGreeting.getId());
Assertions.assertAll("Removing a greeting by id should work",
() -> assertFalse(deletedGreetingOptional.isPresent(), "Found greeting by id when it should be deleted"));
}