BAEL-5779: assertAll vs Multiple Assertions in JUnit5 (#12819)
* Deep vs Shallow copy of an object in java * update indentaions * Create a BMI Caclualtor in Java * Create a BMI Caclualtor in Java * Delete unused packages * BAEL-5708: Create a BMI Calculator in Java * BAEL-5708: Create a BMI Calculator in Java * BAEL-5767:Writing an ArrayList of Strings into a Text File * BAEL-5767:Writing an ArrayList of Strings into a Text File * Deleting files from core-java-io * BAEL-5767: Writing an ArrayList of Strings into a Text File * Removed files from core-java-11-2 * BAEL-5767:Writing an ArrayList of Strings into a Text File * BAEL-5767:Writing an ArrayList of Strings into a Text File * BAEL-5767:Writing an ArrayList of Strings into a Text File * BAEL-5779:assertAll vs Multiple Assertions in JUnit5 * BAEL-5779:assertAll vs Multiple Assertions in JUnit5 * BAEL-5779:assertAll vs Multiple Assertions in JUnit5 * BAEL-5779:assertAll vs Multiple Assertions in JUnit5
This commit is contained in:
parent
7a17abc2aa
commit
fad70d5b4e
@ -0,0 +1,37 @@
|
||||
package com.baeldung.groupedvsmultipleassertions;
|
||||
|
||||
public class User {
|
||||
private String username;
|
||||
private String email;
|
||||
private boolean activated;
|
||||
|
||||
public User(String username, String email, boolean activated) {
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.activated = activated;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public boolean getActivated() {
|
||||
return activated;
|
||||
}
|
||||
|
||||
public void setActivated(boolean activated) {
|
||||
this.activated = activated;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.baeldung.groupedvsmultipleassertions;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class GroupedvsMultipleAssertionsUnitTest {
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void givenAssertAll_whenSingleAssertStatementFails_thenRestWillStillBeExecuted() {
|
||||
User user = new User("baeldung", "support@baeldung.com", false);
|
||||
assertAll(
|
||||
"Grouped Assertions of User",
|
||||
() -> assertEquals("admin", user.getUsername(), "Username should be admin"),
|
||||
() -> assertEquals("admin@baeldung.com", user.getEmail(), "Email should be admin@baeldung.com"),
|
||||
() -> assertTrue(user.getActivated(), "User should be activated")
|
||||
);
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void givenMultipleAssertions_whenSingleAssertStatementFails_thenRestWillNotBeExecuted() {
|
||||
User user = new User("baeldung", "support@baeldung.com", false);
|
||||
assertEquals("admin", user.getUsername(), "Username should be admin");
|
||||
assertEquals("admin@baeldung.com", user.getEmail(), "Email should be admin@baeldung.com");
|
||||
assertTrue(user.getActivated(), "User should be activated");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user