From d722c0d1d17eaa780333d3a53ec0036396719acc Mon Sep 17 00:00:00 2001 From: Alex Golub Date: Wed, 20 Apr 2022 13:57:15 +0300 Subject: [PATCH] Reformat Put each assertion on separate line to improve readability Explain why test is marked @Disabled --- .../test/java/com/baeldung/FirstUnitTest.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/FirstUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/FirstUnitTest.java index c47a70e52f..a5304d3402 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/FirstUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/FirstUnitTest.java @@ -1,12 +1,12 @@ 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.List; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; class FirstUnitTest { @@ -14,20 +14,24 @@ class FirstUnitTest { void lambdaExpressions() { List numbers = Arrays.asList(1, 2, 3); assertTrue(numbers.stream() - .mapToInt(i -> i) - .sum() > 5, "Sum should be greater than 5"); + .mapToInt(Integer::intValue) + .sum() > 5, "Sum should be greater than 5"); } @Disabled("test to show MultipleFailuresError") @Test void groupAssertions() { - int[] numbers = { 0, 1, 2, 3, 4 }; - assertAll("numbers", () -> assertEquals(numbers[0], 1), () -> assertEquals(numbers[3], 3), () -> assertEquals(numbers[4], 1)); + int[] numbers = {0, 1, 2, 3, 4}; + assertAll("numbers", + () -> assertEquals(numbers[0], 1), + () -> assertEquals(numbers[3], 3), + () -> assertEquals(numbers[4], 1) + ); } @Test - @Disabled + @Disabled("Disabled test example") void disabledTest() { - assertTrue(false); + fail(); } }