diff --git a/pom.xml b/pom.xml index 28a6dd358e..da1733d2b2 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,12 @@ ${junit-jupiter.version} test + + org.junit.jupiter + junit-jupiter-params + ${junit-jupiter.version} + test + org.junit.jupiter junit-jupiter-api diff --git a/core-java/src/main/java/com/baeldung/throwsexception/Calculator.java b/testing-modules/junit-5/src/main/java/com/baeldung/throwsexception/Calculator.java similarity index 100% rename from core-java/src/main/java/com/baeldung/throwsexception/Calculator.java rename to testing-modules/junit-5/src/main/java/com/baeldung/throwsexception/Calculator.java diff --git a/core-java/src/main/java/com/baeldung/throwsexception/DivideByZeroException.java b/testing-modules/junit-5/src/main/java/com/baeldung/throwsexception/DivideByZeroException.java similarity index 100% rename from core-java/src/main/java/com/baeldung/throwsexception/DivideByZeroException.java rename to testing-modules/junit-5/src/main/java/com/baeldung/throwsexception/DivideByZeroException.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java rename to testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java rename to testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SummationServiceIntegrationTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SummationServiceIntegrationTest.java new file mode 100644 index 0000000000..92e7a6f5db --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SummationServiceIntegrationTest.java @@ -0,0 +1,53 @@ +package com.baeldung.junit5vstestng; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class SummationServiceIntegrationTest { + private static List numbers; + + @BeforeAll + public static void initialize() { + numbers = new ArrayList<>(); + } + + @AfterAll + public static void tearDown() { + numbers = null; + } + + @BeforeEach + public void runBeforeEachTest() { + numbers.add(1); + numbers.add(2); + numbers.add(3); + } + + @AfterEach + public void runAfterEachTest() { + numbers.clear(); + } + + @Test + public void givenNumbers_sumEquals_thenCorrect() { + int sum = numbers.stream() + .reduce(0, Integer::sum); + Assert.assertEquals(6, sum); + } + + @Ignore + @Test + public void givenEmptyList_sumEqualsZero_thenCorrect() { + int sum = numbers.stream() + .reduce(0, Integer::sum); + Assert.assertEquals(6, sum); + } +} diff --git a/core-java/src/test/java/com/baeldung/throwsexception/CalculatorUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/throwsexception/CalculatorUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/throwsexception/CalculatorUnitTest.java rename to testing-modules/junit-5/src/test/java/com/baeldung/throwsexception/CalculatorUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/customtestname/CustomNameUnitTest.java b/testing-modules/junit-5/src/test/java/org/baeldung/java/customtestname/CustomNameUnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/customtestname/CustomNameUnitTest.java rename to testing-modules/junit-5/src/test/java/org/baeldung/java/customtestname/CustomNameUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/parameterisedsource/ParameterizedUnitTest.java b/testing-modules/junit-5/src/test/java/org/baeldung/java/parameterisedsource/ParameterizedUnitTest.java similarity index 93% rename from core-java/src/test/java/org/baeldung/java/parameterisedsource/ParameterizedUnitTest.java rename to testing-modules/junit-5/src/test/java/org/baeldung/java/parameterisedsource/ParameterizedUnitTest.java index af9ad870b9..8d09161176 100644 --- a/core-java/src/test/java/org/baeldung/java/parameterisedsource/ParameterizedUnitTest.java +++ b/testing-modules/junit-5/src/test/java/org/baeldung/java/parameterisedsource/ParameterizedUnitTest.java @@ -1,6 +1,5 @@ package org.baeldung.java.parameterisedsource; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -13,8 +12,6 @@ import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; -import com.baeldung.enums.PizzaDeliveryStrategy; - public class ParameterizedUnitTest { @ParameterizedTest diff --git a/testing-modules/junit-5/src/test/java/org/baeldung/java/parameterisedsource/PizzaDeliveryStrategy.java b/testing-modules/junit-5/src/test/java/org/baeldung/java/parameterisedsource/PizzaDeliveryStrategy.java new file mode 100644 index 0000000000..ecfc7b4627 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/org/baeldung/java/parameterisedsource/PizzaDeliveryStrategy.java @@ -0,0 +1,6 @@ +package org.baeldung.java.parameterisedsource; + +public enum PizzaDeliveryStrategy { + EXPRESS, + NORMAL; +} diff --git a/core-java/src/test/java/org/baeldung/java/suite/SelectClassesSuiteUnitTest.java b/testing-modules/junit-5/src/test/java/org/baeldung/java/suite/SelectClassesSuiteUnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/suite/SelectClassesSuiteUnitTest.java rename to testing-modules/junit-5/src/test/java/org/baeldung/java/suite/SelectClassesSuiteUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/suite/SelectPackagesSuiteUnitTest.java b/testing-modules/junit-5/src/test/java/org/baeldung/java/suite/SelectPackagesSuiteUnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/suite/SelectPackagesSuiteUnitTest.java rename to testing-modules/junit-5/src/test/java/org/baeldung/java/suite/SelectPackagesSuiteUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/suite/childpackage1/Class1UnitTest.java b/testing-modules/junit-5/src/test/java/org/baeldung/java/suite/childpackage1/Class1UnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/suite/childpackage1/Class1UnitTest.java rename to testing-modules/junit-5/src/test/java/org/baeldung/java/suite/childpackage1/Class1UnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/suite/childpackage2/Class2UnitTest.java b/testing-modules/junit-5/src/test/java/org/baeldung/java/suite/childpackage2/Class2UnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/suite/childpackage2/Class2UnitTest.java rename to testing-modules/junit-5/src/test/java/org/baeldung/java/suite/childpackage2/Class2UnitTest.java