BAEL-701 - TestNG reformatting
This commit is contained in:
parent
95e24dac2a
commit
efdd45259f
196
testng/pom.xml
196
testng/pom.xml
@ -1,121 +1,121 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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"
|
<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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>testng</name>
|
<name>testng</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- logging -->
|
<!-- logging -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>${org.slf4j.version}</version>
|
<version>${org.slf4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>${logback.version}</version>
|
<version>${logback.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- test scoped -->
|
<!-- test scoped -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testng</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>${testng.version}</version>
|
<version>${testng.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>testng</finalName>
|
<finalName>testng</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<testResources>
|
<testResources>
|
||||||
<testResource>
|
<testResource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</testResource>
|
</testResource>
|
||||||
</testResources>
|
</testResources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/*IntegrationTest.java</exclude>
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||||
<exclude>**/*ManualTest.java</exclude>
|
<exclude>**/*ManualTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<suiteXmlFiles>
|
<suiteXmlFiles>
|
||||||
<suiteXmlFile>src\test\resources\parametrized_testng.xml</suiteXmlFile>
|
<suiteXmlFile>src\test\resources\parametrized_testng.xml</suiteXmlFile>
|
||||||
<suiteXmlFile>src\test\resources\test_group.xml</suiteXmlFile>
|
<suiteXmlFile>src\test\resources\test_group.xml</suiteXmlFile>
|
||||||
<suiteXmlFile>src\test\resources\test_setup.xml</suiteXmlFile>
|
<suiteXmlFile>src\test\resources\test_setup.xml</suiteXmlFile>
|
||||||
<suiteXmlFile>src\test\resources\test_suite.xml</suiteXmlFile>
|
<suiteXmlFile>src\test\resources\test_suite.xml</suiteXmlFile>
|
||||||
</suiteXmlFiles>
|
</suiteXmlFiles>
|
||||||
|
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>copy-dependencies</id>
|
<id>copy-dependencies</id>
|
||||||
<phase>prepare-package</phase>
|
<phase>prepare-package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>copy-dependencies</goal>
|
<goal>copy-dependencies</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<!-- logging -->
|
<!-- logging -->
|
||||||
<org.slf4j.version>1.7.21</org.slf4j.version>
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
<logback.version>1.1.7</logback.version>
|
<logback.version>1.1.7</logback.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<testng.version>6.10</testng.version>
|
<testng.version>6.10</testng.version>
|
||||||
|
|
||||||
<!-- maven plugins -->
|
<!-- maven plugins -->
|
||||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -6,9 +6,9 @@ import org.testng.annotations.Test;
|
|||||||
public class MultiThreadedTests {
|
public class MultiThreadedTests {
|
||||||
|
|
||||||
@Test(threadPoolSize = 5, invocationCount = 10, timeOut = 1000)
|
@Test(threadPoolSize = 5, invocationCount = 10, timeOut = 1000)
|
||||||
public void givenMethod_whenRunInThreads_thenCorrect(){
|
public void givenMethod_whenRunInThreads_thenCorrect() {
|
||||||
int count = Thread.activeCount();
|
int count = Thread.activeCount();
|
||||||
Assert.assertTrue(count>1);
|
Assert.assertTrue(count > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,39 +6,39 @@ import org.testng.annotations.Test;
|
|||||||
|
|
||||||
public class TestGroup {
|
public class TestGroup {
|
||||||
|
|
||||||
@BeforeGroups("database")
|
@BeforeGroups("database")
|
||||||
public void setupDB() {
|
public void setupDB() {
|
||||||
System.out.println("setupDB()");
|
System.out.println("setupDB()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups("database")
|
@AfterGroups("database")
|
||||||
public void cleanDB() {
|
public void cleanDB() {
|
||||||
System.out.println("cleanDB()");
|
System.out.println("cleanDB()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups= "selenium-test")
|
@Test(groups = "selenium-test")
|
||||||
public void runSelenium() {
|
public void runSelenium() {
|
||||||
System.out.println("runSelenium()");
|
System.out.println("runSelenium()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups= "selenium-test")
|
@Test(groups = "selenium-test")
|
||||||
public void runSelenium1() {
|
public void runSelenium1() {
|
||||||
System.out.println("runSelenium()1");
|
System.out.println("runSelenium()1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "database")
|
@Test(groups = "database")
|
||||||
public void testConnectOracle() {
|
public void testConnectOracle() {
|
||||||
System.out.println("testConnectOracle()");
|
System.out.println("testConnectOracle()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "database")
|
@Test(groups = "database")
|
||||||
public void testConnectMsSQL() {
|
public void testConnectMsSQL() {
|
||||||
System.out.println("testConnectMsSQL");
|
System.out.println("testConnectMsSQL");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnGroups = {"database","selenium-test"})
|
@Test(dependsOnGroups = {"database", "selenium-test"})
|
||||||
public void runFinal() {
|
public void runFinal() {
|
||||||
System.out.println("runFinal");
|
System.out.println("runFinal");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -13,25 +13,25 @@ public class CustomisedListener implements ITestListener {
|
|||||||
public void onFinish(ITestContext arg0) {
|
public void onFinish(ITestContext arg0) {
|
||||||
LOGGER.info("PASSED TEST CASES");
|
LOGGER.info("PASSED TEST CASES");
|
||||||
arg0.getPassedTests()
|
arg0.getPassedTests()
|
||||||
.getAllResults()
|
.getAllResults()
|
||||||
.stream()
|
.stream()
|
||||||
.forEach(result -> {
|
.forEach(result -> {
|
||||||
LOGGER.info(result.getName());
|
LOGGER.info(result.getName());
|
||||||
});
|
});
|
||||||
LOGGER.info("FAILED TEST CASES");
|
LOGGER.info("FAILED TEST CASES");
|
||||||
arg0.getFailedTests()
|
arg0.getFailedTests()
|
||||||
.getAllResults()
|
.getAllResults()
|
||||||
.stream()
|
.stream()
|
||||||
.forEach(result -> {
|
.forEach(result -> {
|
||||||
LOGGER.info(result.getName());
|
LOGGER.info(result.getName());
|
||||||
});
|
});
|
||||||
LOGGER.info("Test completed on: "+arg0.getEndDate().toString());
|
LOGGER.info("Test completed on: " + arg0.getEndDate().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(ITestContext arg0) {
|
public void onStart(ITestContext arg0) {
|
||||||
LOGGER.info("Started testing on: " + arg0.getStartDate()
|
LOGGER.info("Started testing on: " + arg0.getStartDate()
|
||||||
.toString());
|
.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.baeldung.reports;
|
package com.baeldung.reports;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.testng.IReporter;
|
import org.testng.IReporter;
|
||||||
@ -11,6 +8,9 @@ import org.testng.ISuiteResult;
|
|||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
import org.testng.xml.XmlSuite;
|
import org.testng.xml.XmlSuite;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class CustomisedReports implements IReporter {
|
public class CustomisedReports implements IReporter {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger("TEST_REPORT");
|
private static final Logger LOGGER = LoggerFactory.getLogger("TEST_REPORT");
|
||||||
|
|
||||||
@ -18,32 +18,32 @@ public class CustomisedReports implements IReporter {
|
|||||||
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
|
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
|
||||||
|
|
||||||
suites.stream()
|
suites.stream()
|
||||||
.forEach(suite -> {
|
.forEach(suite -> {
|
||||||
String suiteName = suite.getName();
|
String suiteName = suite.getName();
|
||||||
Map<String, ISuiteResult> suiteResults = suite.getResults();
|
Map<String, ISuiteResult> suiteResults = suite.getResults();
|
||||||
suiteResults.values()
|
suiteResults.values()
|
||||||
.stream()
|
.stream()
|
||||||
.forEach(result -> {
|
.forEach(result -> {
|
||||||
ITestContext context
|
ITestContext context
|
||||||
= ((ISuiteResult) result).getTestContext();
|
= ((ISuiteResult) result).getTestContext();
|
||||||
|
|
||||||
LOGGER.info("Passed tests for suite '"
|
LOGGER.info("Passed tests for suite '"
|
||||||
+ suiteName + "' is:"
|
+ suiteName + "' is:"
|
||||||
+ context.getPassedTests()
|
+ context.getPassedTests()
|
||||||
.getAllResults()
|
.getAllResults()
|
||||||
.size());
|
.size());
|
||||||
LOGGER.info("Failed tests for suite '"
|
LOGGER.info("Failed tests for suite '"
|
||||||
+ suiteName + "' is:"
|
+ suiteName + "' is:"
|
||||||
+ context.getFailedTests()
|
+ context.getFailedTests()
|
||||||
.getAllResults()
|
.getAllResults()
|
||||||
.size());
|
.size());
|
||||||
LOGGER.info("Skipped tests for suite '"
|
LOGGER.info("Skipped tests for suite '"
|
||||||
+ suiteName + "' is:"
|
+ suiteName + "' is:"
|
||||||
+ context.getSkippedTests()
|
+ context.getSkippedTests()
|
||||||
.getAllResults()
|
.getAllResults()
|
||||||
.size());
|
.size());
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user