Merge branch 'master' into JAVA-3592
This commit is contained in:
@@ -39,12 +39,6 @@
|
||||
<artifactId>assertj-guava</artifactId>
|
||||
<version>${assertj-guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.javalite</groupId>
|
||||
<artifactId>javalite-common</artifactId>
|
||||
@@ -83,8 +77,7 @@
|
||||
|
||||
<properties>
|
||||
<truth.version>0.32</truth.version>
|
||||
<assertj-guava.version>3.1.0</assertj-guava.version>
|
||||
<assertj-core.version>3.9.0</assertj-core.version>
|
||||
<assertj-guava.version>3.4.0</assertj-guava.version>
|
||||
<assertj-generator.version>2.1.0</assertj-generator.version>
|
||||
<javalite.version>1.4.13</javalite.version>
|
||||
<jgotesting.version>0.12</jgotesting.version>
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ public class AssertJConditionUnitTest {
|
||||
assertThat(member).isNot(senior);
|
||||
fail();
|
||||
} catch (AssertionError e) {
|
||||
assertThat(e).hasMessageContaining("not to be <senior>");
|
||||
assertThat(e).hasMessageContaining("not to be senior");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AssertJConditionUnitTest {
|
||||
assertThat(member).has(nameJohn);
|
||||
fail();
|
||||
} catch (AssertionError e) {
|
||||
assertThat(e).hasMessageContaining("<name John>");
|
||||
assertThat(e).hasMessageContaining("name John");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,10 +109,10 @@
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<scala.version>2.12.6</scala.version> <!--2.11.12 --> <!--2.12.6 -->
|
||||
<gatling.version>3.3.1</gatling.version> <!--2.2.5 --> <!--2.3.1 -->
|
||||
<scala-maven-plugin.version>4.3.0</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
|
||||
<gatling-maven-plugin.version>3.0.4</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
|
||||
<scala.version>2.12.6</scala.version>
|
||||
<gatling.version>3.3.1</gatling.version>
|
||||
<scala-maven-plugin.version>4.3.0</scala-maven-plugin.version>
|
||||
<gatling-maven-plugin.version>3.0.4</gatling-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+4
-4
@@ -23,19 +23,19 @@ public class BeforeAndAfterAnnotationsUnitTest {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
LOG.info("startup");
|
||||
LOG.debug("startup");
|
||||
list = new ArrayList<>(Arrays.asList("test1", "test2"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
LOG.info("teardown");
|
||||
LOG.debug("teardown");
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSize_thenSizeEqualsToInit() {
|
||||
LOG.info("executing test");
|
||||
LOG.debug("executing test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
list.add("another test");
|
||||
@@ -43,7 +43,7 @@ public class BeforeAndAfterAnnotationsUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSizeAgain_thenSizeEqualsToInit() {
|
||||
LOG.info("executing another test");
|
||||
LOG.debug("executing another test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
list.add("yet another test");
|
||||
|
||||
+5
-5
@@ -12,24 +12,24 @@ import org.slf4j.LoggerFactory;
|
||||
public class BeforeClassAndAfterClassAnnotationsUnitTest {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BeforeClassAndAfterClassAnnotationsUnitTest.class);
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
LOG.info("startup - creating DB connection");
|
||||
LOG.debug("startup - creating DB connection");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
LOG.info("closing DB connection");
|
||||
LOG.debug("closing DB connection");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleTest() {
|
||||
LOG.info("simple test");
|
||||
LOG.debug("simple test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anotherSimpleTest() {
|
||||
LOG.info("another simple test");
|
||||
LOG.debug("another simple test");
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -1,18 +1,21 @@
|
||||
package com.baeldung.migration.junit4;
|
||||
|
||||
import com.baeldung.migration.junit4.rules.TraceUnitTestRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.migration.junit4.rules.TraceUnitTestRule;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RuleExampleUnitTest {
|
||||
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RuleExampleUnitTest.class);
|
||||
|
||||
@Rule
|
||||
public final TraceUnitTestRule traceRuleTests = new TraceUnitTestRule();
|
||||
|
||||
@Test
|
||||
public void whenTracingTests() {
|
||||
System.out.println("This is my test");
|
||||
LOGGER.debug("This is my test");
|
||||
/*...*/
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -1,15 +1,19 @@
|
||||
package com.baeldung.migration.junit4.rules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.MultipleFailureException;
|
||||
import org.junit.runners.model.Statement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TraceUnitTestRule implements TestRule {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TraceUnitTestRule.class);
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
|
||||
@@ -18,13 +22,13 @@ public class TraceUnitTestRule implements TestRule {
|
||||
public void evaluate() throws Throwable {
|
||||
List<Throwable> errors = new ArrayList<Throwable>();
|
||||
|
||||
System.out.println("Starting test ... " + description.getMethodName());
|
||||
LOGGER.debug("Starting test ... {}", description.getMethodName());
|
||||
try {
|
||||
base.evaluate();
|
||||
} catch (Throwable e) {
|
||||
errors.add(e);
|
||||
} finally {
|
||||
System.out.println("... test finished. " + description.getMethodName());
|
||||
LOGGER.debug("... test finished. {}", description.getMethodName());
|
||||
}
|
||||
|
||||
MultipleFailureException.assertEmpty(errors);
|
||||
|
||||
+4
-4
@@ -15,21 +15,21 @@ public class BeforeAllAndAfterAllAnnotationsUnitTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
LOG.info("startup - creating DB connection");
|
||||
LOG.debug("startup - creating DB connection");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
LOG.info("closing DB connection");
|
||||
LOG.debug("closing DB connection");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleTest() {
|
||||
LOG.info("simple test");
|
||||
LOG.debug("simple test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anotherSimpleTest() {
|
||||
LOG.info("another simple test");
|
||||
LOG.debug("another simple test");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -23,19 +23,19 @@ public class BeforeEachAndAfterEachAnnotationsUnitTest {
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
LOG.info("startup");
|
||||
LOG.debug("startup");
|
||||
list = new ArrayList<>(Arrays.asList("test1", "test2"));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void teardown() {
|
||||
LOG.info("teardown");
|
||||
LOG.debug("teardown");
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSize_ThenSizeEqualsToInit() {
|
||||
LOG.info("executing test");
|
||||
LOG.debug("executing test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
list.add("another test");
|
||||
@@ -43,7 +43,7 @@ public class BeforeEachAndAfterEachAnnotationsUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSizeAgain_ThenSizeEqualsToInit() {
|
||||
LOG.info("executing another test");
|
||||
LOG.debug("executing another test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
list.add("yet another test");
|
||||
|
||||
+6
-3
@@ -1,19 +1,22 @@
|
||||
package com.baeldung.migration.junit5;
|
||||
|
||||
import com.baeldung.migration.junit5.extensions.TraceUnitExtension;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.baeldung.migration.junit5.extensions.TraceUnitExtension;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@RunWith(JUnitPlatform.class)
|
||||
@ExtendWith(TraceUnitExtension.class)
|
||||
public class RuleExampleUnitTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RuleExampleUnitTest.class);
|
||||
|
||||
@Test
|
||||
public void whenTracingTests() {
|
||||
System.out.println("This is my test");
|
||||
LOGGER.debug("This is my test");
|
||||
/*...*/
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -3,17 +3,21 @@ package com.baeldung.migration.junit5.extensions;
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TraceUnitExtension implements AfterEachCallback, BeforeEachCallback {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TraceUnitExtension.class);
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
System.out.println("Starting test ... " + context.getDisplayName());
|
||||
LOGGER.debug("Starting test ... {}", context.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
System.out.println("... test finished. " + context.getDisplayName());
|
||||
LOGGER.debug("... test finished. {}", context.getDisplayName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-3
@@ -1,7 +1,10 @@
|
||||
package com.baeldung.resourcedirectory;
|
||||
|
||||
import com.baeldung.migration.junit5.extensions.TraceUnitExtension;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
@@ -9,6 +12,8 @@ import java.nio.file.Paths;
|
||||
|
||||
public class ReadResourceDirectoryUnitTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TraceUnitExtension.class);
|
||||
|
||||
@Test
|
||||
public void givenResourcePath_whenReadAbsolutePathWithFile_thenAbsolutePathEndsWithDirectory() {
|
||||
String path = "src/test/resources";
|
||||
@@ -16,7 +21,7 @@ public class ReadResourceDirectoryUnitTest {
|
||||
File file = new File(path);
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
|
||||
System.out.println(absolutePath);
|
||||
LOGGER.debug(absolutePath);
|
||||
Assert.assertTrue(absolutePath.endsWith("src" + File.separator + "test" + File.separator + "resources"));
|
||||
}
|
||||
|
||||
@@ -26,7 +31,7 @@ public class ReadResourceDirectoryUnitTest {
|
||||
|
||||
String absolutePath = resourceDirectory.toFile().getAbsolutePath();
|
||||
|
||||
System.out.println(absolutePath);
|
||||
LOGGER.debug(absolutePath);
|
||||
Assert.assertTrue(absolutePath.endsWith("src" + File.separator + "test" + File.separator + "resources"));
|
||||
}
|
||||
|
||||
@@ -38,7 +43,7 @@ public class ReadResourceDirectoryUnitTest {
|
||||
File file = new File(classLoader.getResource(resourceName).getFile());
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
|
||||
System.out.println(absolutePath);
|
||||
LOGGER.debug(absolutePath);
|
||||
Assert.assertTrue(absolutePath.endsWith(File.separator + "example_resource.txt"));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
<version>${junit-platform.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-console-standalone -->
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-console-standalone</artifactId>
|
||||
|
||||
+7
-7
@@ -3,29 +3,29 @@ package com.baeldung.junit5.order;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.MethodOrderer.Alphanumeric;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
@TestMethodOrder(Alphanumeric.class)
|
||||
@TestMethodOrder(MethodOrderer.MethodName.class)
|
||||
public class AlphanumericOrderUnitTest {
|
||||
private static StringBuilder output = new StringBuilder("");
|
||||
|
||||
|
||||
@Test
|
||||
public void myATest() {
|
||||
output.append("A");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void myBTest() {
|
||||
output.append("B");
|
||||
output.append("B");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void myaTest() {
|
||||
output.append("a");
|
||||
}
|
||||
|
||||
|
||||
@AfterAll
|
||||
public static void assertOutput() {
|
||||
assertEquals(output.toString(), "ABa");
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.baeldung.junit5.order;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class DefaultOrderUnitTest {
|
||||
|
||||
private static StringBuilder output = new StringBuilder("");
|
||||
|
||||
@Test
|
||||
@DisplayName("Test A")
|
||||
public void myATest() {
|
||||
output.append("A");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test B")
|
||||
public void myBTest() {
|
||||
output.append("B");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test C")
|
||||
public void myCTest() {
|
||||
output.append("C");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void assertOutput() {
|
||||
assertEquals(output.toString(), "ABC");
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.baeldung.junit5.order;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
@TestMethodOrder(MethodOrderer.Random.class)
|
||||
public class RandomOrderUnitTest {
|
||||
|
||||
private static StringBuilder output = new StringBuilder("");
|
||||
|
||||
@Test
|
||||
public void myATest() {
|
||||
output.append("A");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void myBTest() {
|
||||
output.append("B");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void myCTest() {
|
||||
output.append("C");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void assertOutput() {
|
||||
assertEquals(output.toString(), "ACB");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
junit.jupiter.execution.order.random.seed=100
|
||||
junit.jupiter.testmethod.order.default = org.junit.jupiter.api.MethodOrderer$DisplayName
|
||||
@@ -37,17 +37,10 @@
|
||||
<version>${junit-platform.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<log4j2.version>2.8.2</log4j2.version>
|
||||
<assertj-core.version>3.11.1</assertj-core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+2
-2
@@ -20,12 +20,12 @@ public class RegisterExtensionSampleExtension implements BeforeAllCallback, Befo
|
||||
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext extensionContext) throws Exception {
|
||||
logger.info("Type {} In beforeAll : {}", type, extensionContext.getDisplayName());
|
||||
logger.debug("Type {} In beforeAll : {}", type, extensionContext.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext extensionContext) throws Exception {
|
||||
logger.info("Type {} In beforeEach : {}", type, extensionContext.getDisplayName());
|
||||
logger.debug("Type {} In beforeEach : {}", type, extensionContext.getDisplayName());
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
|
||||
+13
-9
@@ -1,41 +1,45 @@
|
||||
package com.baeldung.junit5;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.RepetitionInfo;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class RepeatedTestAnnotationUnitTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RepeatedTestAnnotationUnitTest.class);
|
||||
|
||||
@BeforeEach
|
||||
void beforeEachTest() {
|
||||
System.out.println("Before Each Test");
|
||||
LOGGER.debug("Before Each Test");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void afterEachTest() {
|
||||
System.out.println("After Each Test");
|
||||
System.out.println("=====================");
|
||||
LOGGER.debug("After Each Test");
|
||||
LOGGER.debug("=====================");
|
||||
}
|
||||
|
||||
@RepeatedTest(3)
|
||||
void repeatedTest(TestInfo testInfo) {
|
||||
System.out.println("Executing repeated test");
|
||||
LOGGER.debug("Executing repeated test");
|
||||
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
|
||||
}
|
||||
|
||||
@RepeatedTest(value = 3, name = RepeatedTest.LONG_DISPLAY_NAME)
|
||||
void repeatedTestWithLongName() {
|
||||
System.out.println("Executing repeated test with long name");
|
||||
LOGGER.debug("Executing repeated test with long name");
|
||||
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
|
||||
}
|
||||
|
||||
@RepeatedTest(value = 3, name = RepeatedTest.SHORT_DISPLAY_NAME)
|
||||
void repeatedTestWithShortName() {
|
||||
System.out.println("Executing repeated test with long name");
|
||||
LOGGER.debug("Executing repeated test with long name");
|
||||
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
|
||||
}
|
||||
|
||||
@@ -46,7 +50,7 @@ public class RepeatedTestAnnotationUnitTest {
|
||||
|
||||
@RepeatedTest(3)
|
||||
void repeatedTestWithRepetitionInfo(RepetitionInfo repetitionInfo) {
|
||||
System.out.println("Repetition #" + repetitionInfo.getCurrentRepetition());
|
||||
LOGGER.debug("Repetition # {}", repetitionInfo.getCurrentRepetition());
|
||||
assertEquals(3, repetitionInfo.getTotalRepetitions());
|
||||
}
|
||||
}
|
||||
|
||||
+32
-17
@@ -2,7 +2,20 @@ package com.baeldung.junit5.conditional;
|
||||
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.*;
|
||||
import org.junit.jupiter.api.condition.DisabledForJreRange;
|
||||
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
|
||||
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
|
||||
import org.junit.jupiter.api.condition.DisabledOnJre;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||||
import org.junit.jupiter.api.condition.EnabledOnJre;
|
||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -11,64 +24,66 @@ import java.lang.annotation.Target;
|
||||
|
||||
public class ConditionalAnnotationsUnitTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ConditionalAnnotationsUnitTest.class);
|
||||
|
||||
@Test
|
||||
@EnabledOnOs({OS.WINDOWS, OS.MAC})
|
||||
public void shouldRunBothWindowsAndMac() {
|
||||
System.out.println("runs on Windows and Mac");
|
||||
LOGGER.debug("runs on Windows and Mac");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(OS.LINUX)
|
||||
public void shouldNotRunAtLinux() {
|
||||
System.out.println("will not run on Linux");
|
||||
LOGGER.debug("will not run on Linux");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnJre({JRE.JAVA_10, JRE.JAVA_11})
|
||||
public void shouldOnlyRunOnJava10And11() {
|
||||
System.out.println("runs with java 10 and 11");
|
||||
LOGGER.debug("runs with java 10 and 11");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForJreRange(min = JRE.JAVA_8, max = JRE.JAVA_13)
|
||||
public void shouldOnlyRunOnJava8UntilJava13() {
|
||||
System.out.println("runs with Java 8, 9, 10, 11, 12 and 13!");
|
||||
LOGGER.debug("runs with Java 8, 9, 10, 11, 12 and 13!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledForJreRange(min = JRE.JAVA_14, max = JRE.JAVA_15)
|
||||
public void shouldNotBeRunOnJava14AndJava15() {
|
||||
System.out.println("Shouldn't be run on Java 14 and 15.");
|
||||
LOGGER.debug("Shouldn't be run on Java 14 and 15.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnJre(JRE.OTHER)
|
||||
public void thisTestOnlyRunsWithUpToDateJREs() {
|
||||
System.out.println("this test will only run on java8, 9, 10 and 11.");
|
||||
LOGGER.debug("this test will only run on java8, 9, 10 and 11.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIfSystemProperty(named = "java.vm.vendor", matches = "Oracle.*")
|
||||
public void onlyIfVendorNameStartsWithOracle() {
|
||||
System.out.println("runs only if vendor name starts with Oracle");
|
||||
LOGGER.debug("runs only if vendor name starts with Oracle");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledIfSystemProperty(named = "file.separator", matches = "[/]")
|
||||
public void disabledIfFileSeperatorIsSlash() {
|
||||
System.out.println("Will not run if file.sepeartor property is /");
|
||||
LOGGER.debug("Will not run if file.sepeartor property is /");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIfEnvironmentVariable(named = "GDMSESSION", matches = "ubuntu")
|
||||
public void onlyRunOnUbuntuServer() {
|
||||
System.out.println("only runs if GDMSESSION is ubuntu");
|
||||
LOGGER.debug("only runs if GDMSESSION is ubuntu");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledIfEnvironmentVariable(named = "LC_TIME", matches = ".*UTF-8.")
|
||||
public void shouldNotRunWhenTimeIsNotUTF8() {
|
||||
System.out.println("will not run if environment variable LC_TIME is UTF-8");
|
||||
LOGGER.debug("will not run if environment variable LC_TIME is UTF-8");
|
||||
}
|
||||
|
||||
// Commented codes are going to work prior JUnit 5.5
|
||||
@@ -76,13 +91,13 @@ public class ConditionalAnnotationsUnitTest {
|
||||
@Test
|
||||
// @EnabledIf("'FR' == systemProperty.get('user.country')")
|
||||
public void onlyFrenchPeopleWillRunThisMethod() {
|
||||
System.out.println("will run only if user.country is FR");
|
||||
LOGGER.debug("will run only if user.country is FR");
|
||||
}
|
||||
|
||||
@Test
|
||||
// @DisabledIf("java.lang.System.getProperty('os.name').toLowerCase().contains('mac')")
|
||||
public void shouldNotRunOnMacOS() {
|
||||
System.out.println("will not run if our os.name is mac");
|
||||
LOGGER.debug("will not run if our os.name is mac");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,14 +112,14 @@ public class ConditionalAnnotationsUnitTest {
|
||||
engine = "nashorn",
|
||||
reason = "Self-fulfilling: {result}")*/
|
||||
public void onlyRunsInFebruary() {
|
||||
System.out.println("this test only runs in February");
|
||||
LOGGER.debug("this test only runs in February");
|
||||
}
|
||||
|
||||
@Test
|
||||
/*@DisabledIf("systemEnvironment.get('XPC_SERVICE_NAME') != null " +
|
||||
"&& systemEnvironment.get('XPC_SERVICE_NAME').contains('intellij')")*/
|
||||
public void notValidForIntelliJ() {
|
||||
System.out.println("this test will run if our ide is INTELLIJ");
|
||||
LOGGER.debug("this test will run if our ide is INTELLIJ");
|
||||
}
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@@ -117,7 +132,7 @@ public class ConditionalAnnotationsUnitTest {
|
||||
|
||||
@ThisTestWillOnlyRunAtLinuxAndMacWithJava9Or10Or11
|
||||
public void someSuperTestMethodHere() {
|
||||
System.out.println("this method will run with java9, 10, 11 and Linux or macOS.");
|
||||
LOGGER.debug("this method will run with java9, 10, 11 and Linux or macOS.");
|
||||
}
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@@ -129,6 +144,6 @@ public class ConditionalAnnotationsUnitTest {
|
||||
@RepeatedTest(2)
|
||||
@CoinToss
|
||||
public void gamble() {
|
||||
System.out.println("This tests run status is a gamble with %50 rate");
|
||||
LOGGER.debug("This tests run status is a gamble with %50 rate");
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -3,11 +3,16 @@ package com.baeldung.junit5.templates;
|
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class DisabledOnQAEnvironmentExtension implements ExecutionCondition {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DisabledOnQAEnvironmentExtension.class);
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
Properties properties = new Properties();
|
||||
@@ -16,7 +21,7 @@ public class DisabledOnQAEnvironmentExtension implements ExecutionCondition {
|
||||
.getResourceAsStream("application.properties"));
|
||||
if ("qa".equalsIgnoreCase(properties.getProperty("env"))) {
|
||||
String reason = String.format("The test '%s' is disabled on QA environment", context.getDisplayName());
|
||||
System.out.println(reason);
|
||||
LOGGER.debug(reason);
|
||||
return ConditionEvaluationResult.disabled(reason);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
+16
-5
@@ -1,6 +1,15 @@
|
||||
package com.baeldung.junit5.templates;
|
||||
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
|
||||
import org.junit.jupiter.api.extension.Extension;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
|
||||
import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
@@ -9,6 +18,8 @@ import static java.util.Arrays.asList;
|
||||
|
||||
public class UserIdGeneratorTestInvocationContextProvider implements TestTemplateInvocationContextProvider {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserIdGeneratorTestInvocationContextProvider.class);
|
||||
|
||||
@Override
|
||||
public boolean supportsTestTemplate(ExtensionContext extensionContext) {
|
||||
return true;
|
||||
@@ -44,13 +55,13 @@ public class UserIdGeneratorTestInvocationContextProvider implements TestTemplat
|
||||
new BeforeTestExecutionCallback() {
|
||||
@Override
|
||||
public void beforeTestExecution(ExtensionContext extensionContext) {
|
||||
System.out.println("BeforeTestExecutionCallback:Disabled context");
|
||||
LOGGER.debug("BeforeTestExecutionCallback:Disabled context");
|
||||
}
|
||||
},
|
||||
new AfterTestExecutionCallback() {
|
||||
@Override
|
||||
public void afterTestExecution(ExtensionContext extensionContext) {
|
||||
System.out.println("AfterTestExecutionCallback:Disabled context");
|
||||
LOGGER.debug("AfterTestExecutionCallback:Disabled context");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -72,13 +83,13 @@ public class UserIdGeneratorTestInvocationContextProvider implements TestTemplat
|
||||
new BeforeEachCallback() {
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext extensionContext) {
|
||||
System.out.println("BeforeEachCallback:Enabled context");
|
||||
LOGGER.debug("BeforeEachCallback:Enabled context");
|
||||
}
|
||||
},
|
||||
new AfterEachCallback() {
|
||||
@Override
|
||||
public void afterEach(ExtensionContext extensionContext) {
|
||||
System.out.println("AfterEachCallback:Enabled context");
|
||||
LOGGER.debug("AfterEachCallback:Enabled context");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,57 +57,11 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!--<testSourceDirectory>src/test/scala</testSourceDirectory> -->
|
||||
<!--<pluginManagement> -->
|
||||
<!--<plugins> -->
|
||||
<!--<plugin> -->
|
||||
<!--<groupId>net.alchim31.maven</groupId> -->
|
||||
<!--<artifactId>scala-maven-plugin</artifactId> -->
|
||||
<!--<version>${scala-maven-plugin.version}</version> -->
|
||||
<!--</plugin> -->
|
||||
<!--</plugins> -->
|
||||
<!--</pluginManagement> -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!--<plugin> -->
|
||||
<!--<groupId>net.alchim31.maven</groupId> -->
|
||||
<!--<artifactId>scala-maven-plugin</artifactId> -->
|
||||
<!--<executions> -->
|
||||
<!--<execution> -->
|
||||
<!--<goals> -->
|
||||
<!--<goal>testCompile</goal> -->
|
||||
<!--</goals> -->
|
||||
<!--<configuration> -->
|
||||
<!--<args> -->
|
||||
<!--<!–<arg>-Ybackend:GenBCode</arg> –> -->
|
||||
<!--<arg>-Ydelambdafy:method</arg> -->
|
||||
<!--<arg>-target:jvm-1.8</arg> -->
|
||||
<!--<arg>-deprecation</arg> -->
|
||||
<!--<arg>-feature</arg> -->
|
||||
<!--<arg>-unchecked</arg> -->
|
||||
<!--<arg>-language:implicitConversions</arg> -->
|
||||
<!--<arg>-language:postfixOps</arg> -->
|
||||
<!--</args> -->
|
||||
<!--</configuration> -->
|
||||
<!--</execution> -->
|
||||
<!--</executions> -->
|
||||
<!--</plugin> -->
|
||||
<!--<plugin> -->
|
||||
<!--<groupId>io.gatling</groupId> -->
|
||||
<!--<artifactId>gatling-maven-plugin</artifactId> -->
|
||||
<!--<version>${gatling-maven-plugin.version}</version> -->
|
||||
<!--<executions> -->
|
||||
<!--<execution> -->
|
||||
<!--<phase>test</phase> -->
|
||||
<!--<goals> -->
|
||||
<!--<goal>execute</goal> -->
|
||||
<!--</goals> -->
|
||||
<!--</execution> -->
|
||||
<!--</executions> -->
|
||||
<!--</plugin> -->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -115,10 +69,10 @@
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<scala.version>2.12.12</scala.version> <!--2.11.12 --> <!--2.12.6 -->
|
||||
<gatling.version>3.4.0</gatling.version> <!--2.2.5 --> <!--2.3.1 -->
|
||||
<scala-maven-plugin.version>4.4.0</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
|
||||
<gatling-maven-plugin.version>3.1.0</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
|
||||
<scala.version>2.12.12</scala.version>
|
||||
<gatling.version>3.4.0</gatling.version>
|
||||
<scala-maven-plugin.version>4.4.0</scala-maven-plugin.version>
|
||||
<gatling-maven-plugin.version>3.1.0</gatling-maven-plugin.version>
|
||||
<jmeter.version>5.0</jmeter.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -22,17 +22,10 @@
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<mockito.version>3.8.0</mockito.version>
|
||||
<assertj.version>3.8.0</assertj.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -42,7 +42,6 @@
|
||||
<module>spring-testing-2</module>
|
||||
<module>spring-testing</module>
|
||||
<module>test-containers</module>
|
||||
<module>testing-assertions</module>
|
||||
<module>testing-libraries-2</module>
|
||||
<module>testing-libraries</module>
|
||||
<module>testng</module>
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
|
||||
- [Asserting Log Messages With JUnit](https://www.baeldung.com/junit-asserting-logs)
|
||||
- [Assert Two Lists for Equality Ignoring Order in Java](https://www.baeldung.com/java-assert-lists-equality-ignore-order)
|
||||
- [Assert That a Java Optional Has a Certain Value](https://www.baeldung.com/java-optional-assert-value)
|
||||
- [Assert that an Object is from a Specific Type](https://www.baeldung.com/java-assert-object-of-type)
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
@@ -39,7 +33,6 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<assertj-core.version>3.16.1</assertj-core.version>
|
||||
<commons-collections4.version>4.4</commons-collections4.version>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BusinessWorker {
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(BusinessWorker.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BusinessWorker.class);
|
||||
|
||||
public void generateLogs(String msg) {
|
||||
LOGGER.trace(msg);
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.object.type;
|
||||
|
||||
public class Deciduous implements Tree {
|
||||
|
||||
private String name;
|
||||
|
||||
public Deciduous(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEvergreen() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.object.type;
|
||||
|
||||
public class Evergreen implements Tree {
|
||||
|
||||
private String name;
|
||||
|
||||
public Evergreen(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEvergreen() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.baeldung.object.type;
|
||||
|
||||
public interface Tree {
|
||||
|
||||
public boolean isEvergreen();
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.object.type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TreeSorter {
|
||||
protected Tree sortTree(String name) {
|
||||
|
||||
final List<String> deciduous = List.of("Beech", "Birch", "Ash", "Whitebeam", "Hornbeam", "Hazel & Willow");
|
||||
final List<String> evergreen = List.of("Cedar", "Holly", "Laurel", "Olive", "Pine");
|
||||
|
||||
if (deciduous.contains(name)) {
|
||||
return new Deciduous(name);
|
||||
} else if (evergreen.contains(name)) {
|
||||
return new Evergreen(name);
|
||||
} else {
|
||||
throw new RuntimeException("Tree could not be classified");
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.baeldung.object.type;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class TreeSorterAssertJUnitTest {
|
||||
private final TreeSorter tested = new TreeSorter();
|
||||
|
||||
@Test
|
||||
public void sortTreeShouldReturnEvergreen_WhenPineIsPassed() {
|
||||
Tree tree = tested.sortTree("Pine");
|
||||
assertThat(tree).isExactlyInstanceOf(Evergreen.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortTreeShouldReturnDecidious_WhenBirchIsPassed() {
|
||||
Tree tree = tested.sortTree("Birch");
|
||||
assertThat(tree).hasSameClassAs(new Deciduous("Birch"));
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.object.type;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class TreeSorterHamcrestUnitTest {
|
||||
private final TreeSorter tested = new TreeSorter();
|
||||
|
||||
@Test
|
||||
public void sortTreeShouldReturnEvergreen_WhenPineIsPassed() {
|
||||
Tree tree = tested.sortTree("Pine");
|
||||
//with JUnit assertEquals:
|
||||
assertEquals(tree.getClass(), Evergreen.class);
|
||||
//with Hamcrest instanceOf:
|
||||
assertThat(tree, instanceOf(Evergreen.class));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortTreeShouldReturnDecidious_WhenBirchIsPassed() {
|
||||
Tree tree = tested.sortTree("Birch");
|
||||
assertThat(tree, instanceOf(Deciduous.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,12 +30,6 @@
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.stefanbirkner</groupId>
|
||||
<artifactId>system-rules</artifactId>
|
||||
@@ -114,7 +108,6 @@
|
||||
<system-rules.version>1.19.0</system-rules.version>
|
||||
<system-lambda.version>1.0.0</system-lambda.version>
|
||||
<system-stubs.version>1.1.0</system-stubs.version>
|
||||
<assertj-core.version>3.16.1</assertj-core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
@@ -16,7 +16,6 @@
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- test scoped -->
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
@@ -41,8 +40,46 @@
|
||||
</testResources>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>default-second</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src\test\resources\parametrized_testng.xml</suiteXmlFile>
|
||||
<suiteXmlFile>src\test\resources\test_suite.xml</suiteXmlFile>
|
||||
<suiteXmlFile>src\test\resources\test_unit.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>integration-lite-second</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src\test\resources\test_group.xml</suiteXmlFile>
|
||||
<suiteXmlFile>src\test\resources\test_setup.xml</suiteXmlFile>
|
||||
<suiteXmlFile>src\test\resources\test_int.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<!-- testing -->
|
||||
<testng.version>7.1.0</testng.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
<suite name="int">
|
||||
<test name="integration tests">
|
||||
<classes>
|
||||
<class name="com.baeldung.GroupIntegrationTest" />
|
||||
<class name="com.baeldung.MultiThreadedIntegrationTest" />
|
||||
<class name="com.baeldung.TimeOutIntegrationTest" />
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
<suite name="unit">
|
||||
<test name="unit tests">
|
||||
<classes>
|
||||
<class name="com.baeldung.DependentLongRunningUnitTest" />
|
||||
<class name="com.baeldung.PriorityLongRunningUnitTest" />
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
Reference in New Issue
Block a user