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