Reformat
Put each assertion on separate line to improve readability Explain why test is marked @Disabled
This commit is contained in:
parent
73e2047689
commit
d722c0d1d1
|
@ -1,12 +1,12 @@
|
||||||
package com.baeldung;
|
package com.baeldung;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
class FirstUnitTest {
|
class FirstUnitTest {
|
||||||
|
|
||||||
|
@ -14,20 +14,24 @@ class FirstUnitTest {
|
||||||
void lambdaExpressions() {
|
void lambdaExpressions() {
|
||||||
List<Integer> numbers = Arrays.asList(1, 2, 3);
|
List<Integer> numbers = Arrays.asList(1, 2, 3);
|
||||||
assertTrue(numbers.stream()
|
assertTrue(numbers.stream()
|
||||||
.mapToInt(i -> i)
|
.mapToInt(Integer::intValue)
|
||||||
.sum() > 5, "Sum should be greater than 5");
|
.sum() > 5, "Sum should be greater than 5");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("test to show MultipleFailuresError")
|
@Disabled("test to show MultipleFailuresError")
|
||||||
@Test
|
@Test
|
||||||
void groupAssertions() {
|
void groupAssertions() {
|
||||||
int[] numbers = { 0, 1, 2, 3, 4 };
|
int[] numbers = {0, 1, 2, 3, 4};
|
||||||
assertAll("numbers", () -> assertEquals(numbers[0], 1), () -> assertEquals(numbers[3], 3), () -> assertEquals(numbers[4], 1));
|
assertAll("numbers",
|
||||||
|
() -> assertEquals(numbers[0], 1),
|
||||||
|
() -> assertEquals(numbers[3], 3),
|
||||||
|
() -> assertEquals(numbers[4], 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Disabled
|
@Disabled("Disabled test example")
|
||||||
void disabledTest() {
|
void disabledTest() {
|
||||||
assertTrue(false);
|
fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue