當前位置: 首頁>>代碼示例>>Java>>正文


Java Assertions.assertAll方法代碼示例

本文整理匯總了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"));

}
 
開發者ID:bmariesan,項目名稱:iStudent,代碼行數:18,代碼來源:GreetingServiceTest.java

示例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"));
}
 
開發者ID:bmariesan,項目名稱:iStudent,代碼行數:10,代碼來源:GreetingServiceTest.java

示例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"));

}
 
開發者ID:bmariesan,項目名稱:iStudent,代碼行數:16,代碼來源:GreetingServiceTest.java

示例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"));

}
 
開發者ID:bmariesan,項目名稱:iStudent,代碼行數:15,代碼來源:GreetingServiceTest.java


注:本文中的org.junit.jupiter.api.Assertions.assertAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。