Merge pull request #7689 from sjmillington/testing-libraries
[BAEL-16669] moved testing-modules/testing modules into relevant folders
This commit is contained in:
commit
4e7b8cf19d
81
assertion-libraries/pom.xml
Normal file
81
assertion-libraries/pom.xml
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<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>assertion-libraries</artifactId>
|
||||||
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
<name>assertion-libraries</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-java</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-java</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.truth</groupId>
|
||||||
|
<artifactId>truth</artifactId>
|
||||||
|
<version>${truth.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.truth.extensions</groupId>
|
||||||
|
<artifactId>truth-java8-extension</artifactId>
|
||||||
|
<version>${truth.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<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>
|
||||||
|
<version>${javalite.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jgotesting</groupId>
|
||||||
|
<artifactId>jgotesting</artifactId>
|
||||||
|
<version>${jgotesting.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-assertions-generator-maven-plugin</artifactId>
|
||||||
|
<version>${assertj-generator.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<classes>
|
||||||
|
<param>com.baeldung.testing.assertj.custom.Person</param>
|
||||||
|
</classes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<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-generator.version>2.1.0</assertj-generator.version>
|
||||||
|
<javalite.version>1.4.13</javalite.version>
|
||||||
|
<jgotesting.version>0.12</jgotesting.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj;
|
package com.baeldung.assertj;
|
||||||
|
|
||||||
public class Dog {
|
public class Dog {
|
||||||
private String name;
|
private String name;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj;
|
package com.baeldung.assertj;
|
||||||
|
|
||||||
public class Member {
|
public class Member {
|
||||||
private String name;
|
private String name;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj;
|
package com.baeldung.assertj;
|
||||||
|
|
||||||
public class Person {
|
public class Person {
|
||||||
private String name;
|
private String name;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj.custom;
|
package com.baeldung.assertj.custom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.truth;
|
package com.baeldung.truth;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.truth;
|
package com.baeldung.truth;
|
||||||
|
|
||||||
import com.google.common.truth.ComparableSubject;
|
import com.google.common.truth.ComparableSubject;
|
||||||
import com.google.common.truth.FailureStrategy;
|
import com.google.common.truth.FailureStrategy;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj;
|
package com.baeldung.assertj;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.allOf;
|
import static org.assertj.core.api.Assertions.allOf;
|
||||||
import static org.assertj.core.api.Assertions.anyOf;
|
import static org.assertj.core.api.Assertions.anyOf;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj;
|
package com.baeldung.assertj;
|
||||||
|
|
||||||
import org.assertj.core.util.Maps;
|
import org.assertj.core.util.Maps;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj;
|
package com.baeldung.assertj;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj;
|
package com.baeldung.assertj;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package com.baeldung.testing.assertj.custom;
|
package com.baeldung.assertj.custom;
|
||||||
|
|
||||||
import static com.baeldung.testing.assertj.custom.Assertions.assertThat;
|
import static com.baeldung.assertj.custom.Assertions.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj.custom;
|
package com.baeldung.assertj.custom;
|
||||||
|
|
||||||
public class Assertions {
|
public class Assertions {
|
||||||
public static PersonAssert assertThat(Person actual) {
|
public static PersonAssert assertThat(Person actual) {
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj.custom;
|
package com.baeldung.assertj.custom;
|
||||||
|
|
||||||
import org.assertj.core.api.AbstractAssert;
|
import org.assertj.core.api.AbstractAssert;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj.exceptions;
|
package com.baeldung.assertj.exceptions;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.fail;
|
import static org.assertj.core.api.Assertions.fail;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.assertj.exceptions;
|
package com.baeldung.assertj.exceptions;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.truth;
|
package com.baeldung.truth;
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
@ -6,7 +6,7 @@ import com.google.common.collect.Range;
|
|||||||
import com.google.common.collect.Table;
|
import com.google.common.collect.Table;
|
||||||
import com.google.common.collect.TreeBasedTable;
|
import com.google.common.collect.TreeBasedTable;
|
||||||
import com.google.common.collect.TreeMultiset;
|
import com.google.common.collect.TreeMultiset;
|
||||||
import static com.baeldung.testing.truth.UserSubject.*;
|
import static com.baeldung.truth.UserSubject.*;
|
||||||
import static com.google.common.truth.Truth.*;
|
import static com.google.common.truth.Truth.*;
|
||||||
import static com.google.common.truth.Truth8.*;
|
import static com.google.common.truth.Truth8.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
4
pom.xml
4
pom.xml
@ -796,7 +796,9 @@
|
|||||||
<module>structurizr</module>
|
<module>structurizr</module>
|
||||||
<module>struts-2</module>
|
<module>struts-2</module>
|
||||||
|
|
||||||
|
<module>assertion-libraries</module>
|
||||||
<module>testing-modules</module>
|
<module>testing-modules</module>
|
||||||
|
<module>testing-modules-2</module>
|
||||||
|
|
||||||
<module>twilio</module>
|
<module>twilio</module>
|
||||||
<module>twitter4j</module>
|
<module>twitter4j</module>
|
||||||
@ -1490,7 +1492,9 @@
|
|||||||
<module>structurizr</module>
|
<module>structurizr</module>
|
||||||
<module>struts-2</module>
|
<module>struts-2</module>
|
||||||
|
|
||||||
|
<module>assertion-libraries</module>
|
||||||
<module>testing-modules</module>
|
<module>testing-modules</module>
|
||||||
|
<module>testing-modules-2</module>
|
||||||
|
|
||||||
<module>twilio</module>
|
<module>twilio</module>
|
||||||
<module>twitter4j</module>
|
<module>twitter4j</module>
|
||||||
|
5
testing-modules-2/README.md
Normal file
5
testing-modules-2/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
## Testing Modules
|
||||||
|
|
||||||
|
This is a aggregator module containing several modules focused on testing libraries 2.
|
||||||
|
|
48
testing-modules-2/pom.xml
Normal file
48
testing-modules-2/pom.xml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
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>testing-modules-2</artifactId>
|
||||||
|
<name>testing-modules-2</name>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>..</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insightfullogic</groupId>
|
||||||
|
<artifactId>lambda-behave</artifactId>
|
||||||
|
<version>${lambda-behave.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>info.cukes</groupId>
|
||||||
|
<artifactId>cucumber-junit</artifactId>
|
||||||
|
<version>${cucumber.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>info.cukes</groupId>
|
||||||
|
<artifactId>cucumber-java</artifactId>
|
||||||
|
<version>${cucumber.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>info.cukes</groupId>
|
||||||
|
<artifactId>cucumber-java8</artifactId>
|
||||||
|
<version>${cucumber.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<lambda-behave.version>0.4</lambda-behave.version>
|
||||||
|
<cucumber.version>1.2.5</cucumber.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.calculator;
|
package com.baeldung.calculator;
|
||||||
|
|
||||||
import cucumber.api.CucumberOptions;
|
import cucumber.api.CucumberOptions;
|
||||||
import cucumber.api.junit.Cucumber;
|
import cucumber.api.junit.Cucumber;
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.calculator;
|
package com.baeldung.calculator;
|
||||||
|
|
||||||
import com.baeldung.cucumber.Calculator;
|
import com.baeldung.cucumber.Calculator;
|
||||||
import cucumber.api.java.Before;
|
import cucumber.api.java.Before;
|
@ -1,11 +1,11 @@
|
|||||||
package com.baeldung.mutation.test;
|
package com.baeldung.mutation;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.baeldung.testing.mutation.Palindrome;
|
import com.baeldung.mutation.Palindrome;
|
||||||
|
|
||||||
public class PalindromeUnitTest {
|
public class PalindromeUnitTest {
|
||||||
@Test
|
@Test
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.shopping;
|
package com.baeldung.shopping;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.testing.shopping;
|
package com.baeldung.shopping;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import cucumber.api.java8.En;
|
import cucumber.api.java8.En;
|
@ -1,136 +1,136 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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>org.baeldung</groupId>
|
<groupId>org.baeldung</groupId>
|
||||||
<artifactId>gatling</artifactId>
|
<artifactId>gatling</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>gatling</name>
|
<name>gatling</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../../</relativePath>
|
<relativePath>../../</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.gatling</groupId>
|
<groupId>io.gatling</groupId>
|
||||||
<artifactId>gatling-app</artifactId>
|
<artifactId>gatling-app</artifactId>
|
||||||
<version>${gatling.version}</version>
|
<version>${gatling.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.gatling</groupId>
|
<groupId>io.gatling</groupId>
|
||||||
<artifactId>gatling-recorder</artifactId>
|
<artifactId>gatling-recorder</artifactId>
|
||||||
<version>${gatling.version}</version>
|
<version>${gatling.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.gatling.highcharts</groupId>
|
<groupId>io.gatling.highcharts</groupId>
|
||||||
<artifactId>gatling-charts-highcharts</artifactId>
|
<artifactId>gatling-charts-highcharts</artifactId>
|
||||||
<version>${gatling.version}</version>
|
<version>${gatling.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.scala-lang</groupId>
|
<groupId>org.scala-lang</groupId>
|
||||||
<artifactId>scala-library</artifactId>
|
<artifactId>scala-library</artifactId>
|
||||||
<version>${scala.version}</version>
|
<version>${scala.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.gatling.highcharts</groupId>
|
<groupId>io.gatling.highcharts</groupId>
|
||||||
<artifactId>gatling-charts-highcharts</artifactId>
|
<artifactId>gatling-charts-highcharts</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.gatling</groupId>
|
<groupId>io.gatling</groupId>
|
||||||
<artifactId>gatling-app</artifactId>
|
<artifactId>gatling-app</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.gatling</groupId>
|
<groupId>io.gatling</groupId>
|
||||||
<artifactId>gatling-recorder</artifactId>
|
<artifactId>gatling-recorder</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.scala-lang</groupId>
|
<groupId>org.scala-lang</groupId>
|
||||||
<artifactId>scala-library</artifactId>
|
<artifactId>scala-library</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<testSourceDirectory>src/test/scala</testSourceDirectory>
|
<testSourceDirectory>src/test/scala</testSourceDirectory>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.alchim31.maven</groupId>
|
<groupId>net.alchim31.maven</groupId>
|
||||||
<artifactId>scala-maven-plugin</artifactId>
|
<artifactId>scala-maven-plugin</artifactId>
|
||||||
<version>${scala-maven-plugin.version}</version>
|
<version>${scala-maven-plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.alchim31.maven</groupId>
|
<groupId>net.alchim31.maven</groupId>
|
||||||
<artifactId>scala-maven-plugin</artifactId>
|
<artifactId>scala-maven-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>testCompile</goal>
|
<goal>testCompile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<args>
|
<args>
|
||||||
<!--<arg>-Ybackend:GenBCode</arg> -->
|
<!--<arg>-Ybackend:GenBCode</arg> -->
|
||||||
<arg>-Ydelambdafy:method</arg>
|
<arg>-Ydelambdafy:method</arg>
|
||||||
<arg>-target:jvm-1.8</arg>
|
<arg>-target:jvm-1.8</arg>
|
||||||
<arg>-deprecation</arg>
|
<arg>-deprecation</arg>
|
||||||
<arg>-feature</arg>
|
<arg>-feature</arg>
|
||||||
<arg>-unchecked</arg>
|
<arg>-unchecked</arg>
|
||||||
<arg>-language:implicitConversions</arg>
|
<arg>-language:implicitConversions</arg>
|
||||||
<arg>-language:postfixOps</arg>
|
<arg>-language:postfixOps</arg>
|
||||||
</args>
|
</args>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>simulation</id>
|
<id>simulation</id>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>io.gatling</groupId>
|
<groupId>io.gatling</groupId>
|
||||||
<artifactId>gatling-maven-plugin</artifactId>
|
<artifactId>gatling-maven-plugin</artifactId>
|
||||||
<version>${gatling-maven-plugin.version}</version>
|
<version>${gatling-maven-plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>test</phase>
|
<phase>test</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>execute</goal>
|
<goal>execute</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<disableCompiler>true</disableCompiler>
|
<disableCompiler>true</disableCompiler>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<scala.version>2.12.6</scala.version> <!--2.11.12 --> <!--2.12.6 -->
|
<scala.version>2.12.6</scala.version> <!--2.11.12 --> <!--2.12.6 -->
|
||||||
<gatling.version>2.3.1</gatling.version> <!--2.2.5 --> <!--2.3.1 -->
|
<gatling.version>2.3.1</gatling.version> <!--2.2.5 --> <!--2.3.1 -->
|
||||||
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
|
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
|
||||||
<gatling-maven-plugin.version>2.2.4</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
|
<gatling-maven-plugin.version>2.2.4</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import io.gatling.app.Gatling
|
import io.gatling.app.Gatling
|
||||||
import io.gatling.core.config.GatlingPropertiesBuilder
|
import io.gatling.core.config.GatlingPropertiesBuilder
|
||||||
|
|
||||||
object Engine extends App {
|
object Engine extends App {
|
||||||
|
|
||||||
val props = new GatlingPropertiesBuilder
|
val props = new GatlingPropertiesBuilder
|
||||||
props.dataDirectory(IDEPathHelper.dataDirectory.toString)
|
props.dataDirectory(IDEPathHelper.dataDirectory.toString)
|
||||||
props.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
|
props.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
|
||||||
props.bodiesDirectory(IDEPathHelper.bodiesDirectory.toString)
|
props.bodiesDirectory(IDEPathHelper.bodiesDirectory.toString)
|
||||||
props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
|
props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
|
||||||
|
|
||||||
Gatling.fromMap(props.build)
|
Gatling.fromMap(props.build)
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
import io.gatling.commons.util.PathHelper._
|
import io.gatling.commons.util.PathHelper._
|
||||||
|
|
||||||
object IDEPathHelper {
|
object IDEPathHelper {
|
||||||
|
|
||||||
val gatlingConfUrl: Path = getClass.getClassLoader.getResource("gatling.conf").toURI
|
val gatlingConfUrl: Path = getClass.getClassLoader.getResource("gatling.conf").toURI
|
||||||
val projectRootDir = gatlingConfUrl.ancestor(3)
|
val projectRootDir = gatlingConfUrl.ancestor(3)
|
||||||
|
|
||||||
val mavenSourcesDirectory = projectRootDir / "src" / "test" / "scala"
|
val mavenSourcesDirectory = projectRootDir / "src" / "test" / "scala"
|
||||||
val mavenResourcesDirectory = projectRootDir / "src" / "test" / "resources"
|
val mavenResourcesDirectory = projectRootDir / "src" / "test" / "resources"
|
||||||
val mavenTargetDirectory = projectRootDir / "target"
|
val mavenTargetDirectory = projectRootDir / "target"
|
||||||
val mavenBinariesDirectory = mavenTargetDirectory / "test-classes"
|
val mavenBinariesDirectory = mavenTargetDirectory / "test-classes"
|
||||||
|
|
||||||
val dataDirectory = mavenResourcesDirectory / "data"
|
val dataDirectory = mavenResourcesDirectory / "data"
|
||||||
val bodiesDirectory = mavenResourcesDirectory / "bodies"
|
val bodiesDirectory = mavenResourcesDirectory / "bodies"
|
||||||
|
|
||||||
val recorderOutputDirectory = mavenSourcesDirectory
|
val recorderOutputDirectory = mavenSourcesDirectory
|
||||||
val resultsDirectory = mavenTargetDirectory / "gatling"
|
val resultsDirectory = mavenTargetDirectory / "gatling"
|
||||||
|
|
||||||
val recorderConfigFile = mavenResourcesDirectory / "recorder.conf"
|
val recorderConfigFile = mavenResourcesDirectory / "recorder.conf"
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import io.gatling.recorder.GatlingRecorder
|
import io.gatling.recorder.GatlingRecorder
|
||||||
import io.gatling.recorder.config.RecorderPropertiesBuilder
|
import io.gatling.recorder.config.RecorderPropertiesBuilder
|
||||||
|
|
||||||
object Recorder extends App {
|
object Recorder extends App {
|
||||||
|
|
||||||
val props = new RecorderPropertiesBuilder
|
val props = new RecorderPropertiesBuilder
|
||||||
props.simulationOutputFolder(IDEPathHelper.recorderOutputDirectory.toString)
|
props.simulationOutputFolder(IDEPathHelper.recorderOutputDirectory.toString)
|
||||||
props.simulationPackage("org.baeldung")
|
props.simulationPackage("org.baeldung")
|
||||||
props.bodiesFolder(IDEPathHelper.bodiesDirectory.toString)
|
props.bodiesFolder(IDEPathHelper.bodiesDirectory.toString)
|
||||||
|
|
||||||
GatlingRecorder.fromMap(props.build, Some(IDEPathHelper.recorderConfigFile))
|
GatlingRecorder.fromMap(props.build, Some(IDEPathHelper.recorderConfigFile))
|
||||||
}
|
}
|
||||||
|
@ -1,402 +0,0 @@
|
|||||||
loadLogFile([{
|
|
||||||
"package": "mocks",
|
|
||||||
"name": "ExampleSpockTest",
|
|
||||||
"start": 1553898111660,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "should calculate character occurrences in given string",
|
|
||||||
"start": 1553898111662,
|
|
||||||
"end": 1553898111699,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898111709,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "mocks",
|
|
||||||
"name": "ItemServiceTest",
|
|
||||||
"start": 1553898111714,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "should spy on EventPublisher method call",
|
|
||||||
"start": 1553898111714,
|
|
||||||
"output": [
|
|
||||||
"I've published: item-id\n"
|
|
||||||
],
|
|
||||||
"end": 1553898112250,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "should return items",
|
|
||||||
"start": 1553898112250,
|
|
||||||
"end": 1553898112260,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "should publish events about new non-empty saved offers",
|
|
||||||
"start": 1553898112260,
|
|
||||||
"end": 1553898112267,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "should return different items for different ids lists",
|
|
||||||
"start": 1553898112267,
|
|
||||||
"end": 1553898112280,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "should throw ExternalItemProviderException when ItemProvider fails",
|
|
||||||
"start": 1553898112281,
|
|
||||||
"end": 1553898112294,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "should return different items on subsequent call",
|
|
||||||
"start": 1553898112294,
|
|
||||||
"narrative": "When method is called for the first time\nThen empty list is returned\nWhen method is called for the second time\nThen item with id=1 is returned\nWhen method is called for the thirdtime\nThen item with id=2 is returned",
|
|
||||||
"end": 1553898112298,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "should return items sorted by name",
|
|
||||||
"start": 1553898112299,
|
|
||||||
"end": 1553898112307,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112310,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "FirstSpecification",
|
|
||||||
"name": "FirstSpecification",
|
|
||||||
"start": 1553898112314,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "Should verify notify was called",
|
|
||||||
"start": 1553898112314,
|
|
||||||
"end": 1553898112324,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Should return true value for mock",
|
|
||||||
"start": 1553898112325,
|
|
||||||
"end": 1553898112344,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Should return default value for mock",
|
|
||||||
"start": 1553898112344,
|
|
||||||
"end": 1553898112347,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "numbers to the power of two",
|
|
||||||
"start": 1553898112347,
|
|
||||||
"end": 1553898112358,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Should get an index out of bounds when removing a non-existent item",
|
|
||||||
"start": 1553898112358,
|
|
||||||
"end": 1553898112364,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Should be able to remove from list",
|
|
||||||
"start": 1553898112364,
|
|
||||||
"end": 1553898112366,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "two plus two should equal four",
|
|
||||||
"start": 1553898112366,
|
|
||||||
"end": 1553898112368,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "one plus one should equal two",
|
|
||||||
"start": 1553898112368,
|
|
||||||
"end": 1553898112391,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112394,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "IgnoreTest",
|
|
||||||
"start": 1553898112395,
|
|
||||||
"end": 1553898112395,
|
|
||||||
"result": "skipped"
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "RetryTest",
|
|
||||||
"start": 1553898112403,
|
|
||||||
"end": 1553898112405,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "This title is easy to read for humans",
|
|
||||||
"start": 1553898112407,
|
|
||||||
"end": 1553898112408,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "SeeTest",
|
|
||||||
"start": 1553898112409,
|
|
||||||
"end": 1553898112411,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "StepwiseTest",
|
|
||||||
"start": 1553898112422,
|
|
||||||
"end": 1553898112423,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "NarrativeDescriptionTest",
|
|
||||||
"start": 1553898112427,
|
|
||||||
"narrative": "as a user\n i want to save favourite items \n and then get the list of them",
|
|
||||||
"end": 1553898112433,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "SubjectTest",
|
|
||||||
"start": 1553898112434,
|
|
||||||
"end": 1553898112436,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "IgnoreRestTest",
|
|
||||||
"start": 1553898112437,
|
|
||||||
"end": 1553898112437,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "StackTraceTest",
|
|
||||||
"start": 1553898112438,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "stacktrace",
|
|
||||||
"start": 1553898112438,
|
|
||||||
"exceptions": [
|
|
||||||
"java.lang.RuntimeException: blabla\n\tat extensions.StackTraceTest.stacktrace(StackTraceTest.groovy:10)\n"
|
|
||||||
],
|
|
||||||
"end": 1553898112455,
|
|
||||||
"result": "failed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112470,
|
|
||||||
"result": "failed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "IgnoreIfTest",
|
|
||||||
"start": 1553898112471,
|
|
||||||
"end": 1553898112472,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "RequiresTest",
|
|
||||||
"start": 1553898112473,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "I will run only on Windows",
|
|
||||||
"start": 1553898112474,
|
|
||||||
"end": 1553898112474,
|
|
||||||
"result": "skipped"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112476,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "IssueTest",
|
|
||||||
"start": 1553898112477,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "I'm using Spock configuration file",
|
|
||||||
"start": 1553898112477,
|
|
||||||
"tags": [
|
|
||||||
{
|
|
||||||
"name": "Bug LO-1000",
|
|
||||||
"key": "issue",
|
|
||||||
"value": "LO-1000",
|
|
||||||
"url": "http:\/\/jira.org\/issues\/LO-1000"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112489,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112490,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "TimeoutTest",
|
|
||||||
"start": 1553898112491,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "I will fail after 200 millis",
|
|
||||||
"start": 1553898112491,
|
|
||||||
"end": 1553898112514,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112517,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
||||||
loadLogFile([{
|
|
||||||
"package": "extensions",
|
|
||||||
"name": "RestoreSystemPropertiesTest",
|
|
||||||
"start": 1553898112518,
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"name": "all environment variables will be saved before execution and restored after tests",
|
|
||||||
"start": 1553898112518,
|
|
||||||
"end": 1553898112532,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"end": 1553898112539,
|
|
||||||
"result": "passed",
|
|
||||||
"attachments": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}])
|
|
||||||
|
|
@ -15,4 +15,17 @@
|
|||||||
<relativePath>../../</relativePath>
|
<relativePath>../../</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>pl.pragmatists</groupId>
|
||||||
|
<artifactId>JUnitParams</artifactId>
|
||||||
|
<version>${jUnitParams.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jUnitParams.version>1.1.0</jUnitParams.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,126 +1,126 @@
|
|||||||
package com.baeldung.junit5.mockito;
|
package com.baeldung.junit5.mockito;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.platform.runner.JUnitPlatform;
|
import org.junit.platform.runner.JUnitPlatform;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
import com.baeldung.junit5.mockito.repository.MailClient;
|
import com.baeldung.junit5.mockito.repository.MailClient;
|
||||||
import com.baeldung.junit5.mockito.repository.SettingRepository;
|
import com.baeldung.junit5.mockito.repository.SettingRepository;
|
||||||
import com.baeldung.junit5.mockito.repository.UserRepository;
|
import com.baeldung.junit5.mockito.repository.UserRepository;
|
||||||
import com.baeldung.junit5.mockito.service.DefaultUserService;
|
import com.baeldung.junit5.mockito.service.DefaultUserService;
|
||||||
import com.baeldung.junit5.mockito.service.Errors;
|
import com.baeldung.junit5.mockito.service.Errors;
|
||||||
import com.baeldung.junit5.mockito.service.UserService;
|
import com.baeldung.junit5.mockito.service.UserService;
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
@RunWith(JUnitPlatform.class)
|
@RunWith(JUnitPlatform.class)
|
||||||
public class UserServiceUnitTest {
|
public class UserServiceUnitTest {
|
||||||
|
|
||||||
UserService userService;
|
UserService userService;
|
||||||
SettingRepository settingRepository;
|
SettingRepository settingRepository;
|
||||||
@Mock UserRepository userRepository;
|
@Mock UserRepository userRepository;
|
||||||
@Mock MailClient mailClient;
|
@Mock MailClient mailClient;
|
||||||
|
|
||||||
User user;
|
User user;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void init(@Mock SettingRepository settingRepository) {
|
void init(@Mock SettingRepository settingRepository) {
|
||||||
userService = new DefaultUserService(userRepository, settingRepository, mailClient);
|
userService = new DefaultUserService(userRepository, settingRepository, mailClient);
|
||||||
lenient().when(settingRepository.getUserMinAge()).thenReturn(10);
|
lenient().when(settingRepository.getUserMinAge()).thenReturn(10);
|
||||||
when(settingRepository.getUserNameMinLength()).thenReturn(4);
|
when(settingRepository.getUserNameMinLength()).thenReturn(4);
|
||||||
lenient().when(userRepository.isUsernameAlreadyExists(any(String.class))).thenReturn(false);
|
lenient().when(userRepository.isUsernameAlreadyExists(any(String.class))).thenReturn(false);
|
||||||
this.settingRepository = settingRepository;
|
this.settingRepository = settingRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenValidUser_whenSaveUser_thenSucceed(@Mock MailClient mailClient) {
|
void givenValidUser_whenSaveUser_thenSucceed(@Mock MailClient mailClient) {
|
||||||
// Given
|
// Given
|
||||||
user = new User("Jerry", 12);
|
user = new User("Jerry", 12);
|
||||||
when(userRepository.insert(any(User.class))).then(new Answer<User>() {
|
when(userRepository.insert(any(User.class))).then(new Answer<User>() {
|
||||||
int sequence = 1;
|
int sequence = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User answer(InvocationOnMock invocation) throws Throwable {
|
public User answer(InvocationOnMock invocation) throws Throwable {
|
||||||
User user = (User) invocation.getArgument(0);
|
User user = (User) invocation.getArgument(0);
|
||||||
user.setId(sequence++);
|
user.setId(sequence++);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
userService = new DefaultUserService(userRepository, settingRepository, mailClient);
|
userService = new DefaultUserService(userRepository, settingRepository, mailClient);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
User insertedUser = userService.register(user);
|
User insertedUser = userService.register(user);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
verify(userRepository).insert(user);
|
verify(userRepository).insert(user);
|
||||||
Assertions.assertNotNull(user.getId());
|
Assertions.assertNotNull(user.getId());
|
||||||
verify(mailClient).sendUserRegistrationMail(insertedUser);
|
verify(mailClient).sendUserRegistrationMail(insertedUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenShortName_whenSaveUser_thenGiveShortUsernameError() {
|
void givenShortName_whenSaveUser_thenGiveShortUsernameError() {
|
||||||
// Given
|
// Given
|
||||||
user = new User("tom", 12);
|
user = new User("tom", 12);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
try {
|
try {
|
||||||
userService.register(user);
|
userService.register(user);
|
||||||
fail("Should give an error");
|
fail("Should give an error");
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
assertEquals(ex.getMessage(), Errors.USER_NAME_SHORT);
|
assertEquals(ex.getMessage(), Errors.USER_NAME_SHORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
verify(userRepository, never()).insert(user);
|
verify(userRepository, never()).insert(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenSmallAge_whenSaveUser_thenGiveYoungUserError() {
|
void givenSmallAge_whenSaveUser_thenGiveYoungUserError() {
|
||||||
// Given
|
// Given
|
||||||
user = new User("jerry", 3);
|
user = new User("jerry", 3);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
try {
|
try {
|
||||||
userService.register(user);
|
userService.register(user);
|
||||||
fail("Should give an error");
|
fail("Should give an error");
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
assertEquals(ex.getMessage(), Errors.USER_AGE_YOUNG);
|
assertEquals(ex.getMessage(), Errors.USER_AGE_YOUNG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
verify(userRepository, never()).insert(user);
|
verify(userRepository, never()).insert(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenUserWithExistingName_whenSaveUser_thenGiveUsernameAlreadyExistsError() {
|
void givenUserWithExistingName_whenSaveUser_thenGiveUsernameAlreadyExistsError() {
|
||||||
// Given
|
// Given
|
||||||
user = new User("jerry", 12);
|
user = new User("jerry", 12);
|
||||||
Mockito.reset(userRepository);
|
Mockito.reset(userRepository);
|
||||||
when(userRepository.isUsernameAlreadyExists(any(String.class))).thenReturn(true);
|
when(userRepository.isUsernameAlreadyExists(any(String.class))).thenReturn(true);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
try {
|
try {
|
||||||
userService.register(user);
|
userService.register(user);
|
||||||
fail("Should give an error");
|
fail("Should give an error");
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
assertEquals(ex.getMessage(), Errors.USER_NAME_DUPLICATE);
|
assertEquals(ex.getMessage(), Errors.USER_NAME_DUPLICATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
verify(userRepository, never()).insert(user);
|
verify(userRepository, never()).insert(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,104 +1,104 @@
|
|||||||
package org.baeldung.bddmockito;
|
package org.baeldung.bddmockito;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.BDDMockito.*;
|
import static org.mockito.BDDMockito.*;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
|
|
||||||
|
|
||||||
public class BDDMockitoIntegrationTest {
|
public class BDDMockitoIntegrationTest {
|
||||||
|
|
||||||
PhoneBookService phoneBookService;
|
PhoneBookService phoneBookService;
|
||||||
PhoneBookRepository phoneBookRepository;
|
PhoneBookRepository phoneBookRepository;
|
||||||
|
|
||||||
String momContactName = "Mom";
|
String momContactName = "Mom";
|
||||||
String momPhoneNumber = "01234";
|
String momPhoneNumber = "01234";
|
||||||
String xContactName = "x";
|
String xContactName = "x";
|
||||||
String tooLongPhoneNumber = "01111111111111";
|
String tooLongPhoneNumber = "01111111111111";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
phoneBookRepository = Mockito.mock(PhoneBookRepository.class);
|
phoneBookRepository = Mockito.mock(PhoneBookRepository.class);
|
||||||
phoneBookService = new PhoneBookService(phoneBookRepository);
|
phoneBookService = new PhoneBookService(phoneBookRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenValidContactName_whenSearchInPhoneBook_thenRetunPhoneNumber() {
|
public void givenValidContactName_whenSearchInPhoneBook_thenRetunPhoneNumber() {
|
||||||
given(phoneBookRepository.contains(momContactName)).willReturn(true);
|
given(phoneBookRepository.contains(momContactName)).willReturn(true);
|
||||||
given(phoneBookRepository.getPhoneNumberByContactName(momContactName))
|
given(phoneBookRepository.getPhoneNumberByContactName(momContactName))
|
||||||
.will((InvocationOnMock invocation) -> {
|
.will((InvocationOnMock invocation) -> {
|
||||||
if(invocation.getArgument(0).equals(momContactName)) {
|
if(invocation.getArgument(0).equals(momContactName)) {
|
||||||
return momPhoneNumber;
|
return momPhoneNumber;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
String phoneNumber = phoneBookService.search(momContactName);
|
String phoneNumber = phoneBookService.search(momContactName);
|
||||||
|
|
||||||
then(phoneBookRepository).should().contains(momContactName);
|
then(phoneBookRepository).should().contains(momContactName);
|
||||||
then(phoneBookRepository).should().getPhoneNumberByContactName(momContactName);
|
then(phoneBookRepository).should().getPhoneNumberByContactName(momContactName);
|
||||||
Assert.assertEquals(phoneNumber, momPhoneNumber);
|
Assert.assertEquals(phoneNumber, momPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenInvalidContactName_whenSearch_thenRetunNull() {
|
public void givenInvalidContactName_whenSearch_thenRetunNull() {
|
||||||
given(phoneBookRepository.contains(xContactName)).willReturn(false);
|
given(phoneBookRepository.contains(xContactName)).willReturn(false);
|
||||||
|
|
||||||
String phoneNumber = phoneBookService.search(xContactName);
|
String phoneNumber = phoneBookService.search(xContactName);
|
||||||
|
|
||||||
then(phoneBookRepository).should().contains(xContactName);
|
then(phoneBookRepository).should().contains(xContactName);
|
||||||
then(phoneBookRepository).should(never()).getPhoneNumberByContactName(xContactName);
|
then(phoneBookRepository).should(never()).getPhoneNumberByContactName(xContactName);
|
||||||
Assert.assertEquals(phoneNumber, null);
|
Assert.assertEquals(phoneNumber, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenValidContactNameAndPhoneNumber_whenRegister_thenSucceed() {
|
public void givenValidContactNameAndPhoneNumber_whenRegister_thenSucceed() {
|
||||||
given(phoneBookRepository.contains(momContactName)).willReturn(false);
|
given(phoneBookRepository.contains(momContactName)).willReturn(false);
|
||||||
|
|
||||||
phoneBookService.register(momContactName, momPhoneNumber);
|
phoneBookService.register(momContactName, momPhoneNumber);
|
||||||
|
|
||||||
verify(phoneBookRepository).insert(momContactName, momPhoneNumber);
|
verify(phoneBookRepository).insert(momContactName, momPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenEmptyPhoneNumber_whenRegister_thenFail() {
|
public void givenEmptyPhoneNumber_whenRegister_thenFail() {
|
||||||
given(phoneBookRepository.contains(momContactName)).willReturn(false);
|
given(phoneBookRepository.contains(momContactName)).willReturn(false);
|
||||||
|
|
||||||
phoneBookService.register(xContactName, "");
|
phoneBookService.register(xContactName, "");
|
||||||
|
|
||||||
then(phoneBookRepository).should(never()).insert(momContactName, momPhoneNumber);
|
then(phoneBookRepository).should(never()).insert(momContactName, momPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenLongPhoneNumber_whenRegister_thenFail() {
|
public void givenLongPhoneNumber_whenRegister_thenFail() {
|
||||||
given(phoneBookRepository.contains(xContactName)).willReturn(false);
|
given(phoneBookRepository.contains(xContactName)).willReturn(false);
|
||||||
willThrow(new RuntimeException())
|
willThrow(new RuntimeException())
|
||||||
.given(phoneBookRepository).insert(any(String.class), eq(tooLongPhoneNumber));
|
.given(phoneBookRepository).insert(any(String.class), eq(tooLongPhoneNumber));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
phoneBookService.register(xContactName, tooLongPhoneNumber);
|
phoneBookService.register(xContactName, tooLongPhoneNumber);
|
||||||
fail("Should throw exception");
|
fail("Should throw exception");
|
||||||
} catch (RuntimeException ex) { }
|
} catch (RuntimeException ex) { }
|
||||||
|
|
||||||
then(phoneBookRepository).should(never()).insert(momContactName, tooLongPhoneNumber);
|
then(phoneBookRepository).should(never()).insert(momContactName, tooLongPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenExistentContactName_whenRegister_thenFail() {
|
public void givenExistentContactName_whenRegister_thenFail() {
|
||||||
given(phoneBookRepository.contains(momContactName))
|
given(phoneBookRepository.contains(momContactName))
|
||||||
.willThrow(new RuntimeException("Name already exist"));
|
.willThrow(new RuntimeException("Name already exist"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
phoneBookService.register(momContactName, momPhoneNumber);
|
phoneBookService.register(momContactName, momPhoneNumber);
|
||||||
fail("Should throw exception");
|
fail("Should throw exception");
|
||||||
} catch(Exception ex) { }
|
} catch(Exception ex) { }
|
||||||
|
|
||||||
then(phoneBookRepository).should(never()).insert(momContactName, momPhoneNumber);
|
then(phoneBookRepository).should(never()).insert(momContactName, momPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
package org.baeldung.bddmockito;
|
package org.baeldung.bddmockito;
|
||||||
|
|
||||||
public interface PhoneBookRepository {
|
public interface PhoneBookRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert phone record
|
* Insert phone record
|
||||||
* @param name Contact name
|
* @param name Contact name
|
||||||
* @param phone Phone number
|
* @param phone Phone number
|
||||||
*/
|
*/
|
||||||
void insert(String name, String phone);
|
void insert(String name, String phone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for contact phone number
|
* Search for contact phone number
|
||||||
* @param name Contact name
|
* @param name Contact name
|
||||||
* @return phone number
|
* @return phone number
|
||||||
*/
|
*/
|
||||||
String getPhoneNumberByContactName(String name);
|
String getPhoneNumberByContactName(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the phonebook contains this contact
|
* Check if the phonebook contains this contact
|
||||||
* @param name Contact name
|
* @param name Contact name
|
||||||
* @return true if this contact name exists
|
* @return true if this contact name exists
|
||||||
*/
|
*/
|
||||||
boolean contains(String name);
|
boolean contains(String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
package org.baeldung.bddmockito;
|
package org.baeldung.bddmockito;
|
||||||
|
|
||||||
public class PhoneBookService {
|
public class PhoneBookService {
|
||||||
|
|
||||||
private PhoneBookRepository phoneBookRepository;
|
private PhoneBookRepository phoneBookRepository;
|
||||||
|
|
||||||
public PhoneBookService(PhoneBookRepository phoneBookRepository) {
|
public PhoneBookService(PhoneBookRepository phoneBookRepository) {
|
||||||
this.phoneBookRepository = phoneBookRepository;
|
this.phoneBookRepository = phoneBookRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a contact
|
* Register a contact
|
||||||
* @param name Contact name
|
* @param name Contact name
|
||||||
* @param phone Phone number
|
* @param phone Phone number
|
||||||
*/
|
*/
|
||||||
public void register(String name, String phone) {
|
public void register(String name, String phone) {
|
||||||
if(!name.isEmpty() && !phone.isEmpty() && !phoneBookRepository.contains(name)) {
|
if(!name.isEmpty() && !phone.isEmpty() && !phoneBookRepository.contains(name)) {
|
||||||
phoneBookRepository.insert(name, phone);
|
phoneBookRepository.insert(name, phone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a phone number by contact name
|
* Search for a phone number by contact name
|
||||||
* @param name Contact name
|
* @param name Contact name
|
||||||
* @return Phone number
|
* @return Phone number
|
||||||
*/
|
*/
|
||||||
public String search(String name) {
|
public String search(String name) {
|
||||||
if(!name.isEmpty() && phoneBookRepository.contains(name)) {
|
if(!name.isEmpty() && phoneBookRepository.contains(name)) {
|
||||||
return phoneBookRepository.getPhoneNumberByContactName(name);
|
return phoneBookRepository.getPhoneNumberByContactName(name);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
26
testing-modules/mocks/javafaker/pom.xml
Normal file
26
testing-modules/mocks/javafaker/pom.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<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>
|
||||||
|
<artifactId>javafaker</artifactId>
|
||||||
|
<name>javafaker</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>mocks</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.javafaker</groupId>
|
||||||
|
<artifactId>javafaker</artifactId>
|
||||||
|
<version>${javafaker.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<javafaker.version>0.15</javafaker.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
27
testing-modules/mocks/jukito/pom.xml
Normal file
27
testing-modules/mocks/jukito/pom.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<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>
|
||||||
|
<artifactId>jukito</artifactId>
|
||||||
|
<name>jukito</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>mocks</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jukito</groupId>
|
||||||
|
<artifactId>jukito</artifactId>
|
||||||
|
<version>${jukito.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jukito.version>1.5</jukito.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
70
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/ArticleReader.java
Executable file → Normal file
70
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/ArticleReader.java
Executable file → Normal file
@ -1,36 +1,36 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
public class ArticleReader {
|
public class ArticleReader {
|
||||||
|
|
||||||
private List<BaeldungArticle> articles;
|
private List<BaeldungArticle> articles;
|
||||||
private Iterator<BaeldungArticle> articleIter;
|
private Iterator<BaeldungArticle> articleIter;
|
||||||
|
|
||||||
public ArticleReader() {
|
public ArticleReader() {
|
||||||
this(new ArrayList<>());
|
this(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticleReader(List<BaeldungArticle> articles) {
|
public ArticleReader(List<BaeldungArticle> articles) {
|
||||||
this.articles = articles;
|
this.articles = articles;
|
||||||
this.articleIter = this.articles.iterator();
|
this.articleIter = this.articles.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaeldungArticle> ofTopic(String topic) {
|
public List<BaeldungArticle> ofTopic(String topic) {
|
||||||
return articles
|
return articles
|
||||||
.stream()
|
.stream()
|
||||||
.filter(article -> article
|
.filter(article -> article
|
||||||
.title()
|
.title()
|
||||||
.contains(topic))
|
.contains(topic))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaeldungArticle next() {
|
public BaeldungArticle next() {
|
||||||
return this.articleIter.next();
|
return this.articleIter.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
48
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/BaeldungArticle.java
Executable file → Normal file
48
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/BaeldungArticle.java
Executable file → Normal file
@ -1,25 +1,25 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
public class BaeldungArticle {
|
public class BaeldungArticle {
|
||||||
|
|
||||||
public static BaeldungArticle simpleArticle(String title, String content) {
|
public static BaeldungArticle simpleArticle(String title, String content) {
|
||||||
return new BaeldungArticle(title, content);
|
return new BaeldungArticle(title, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
private BaeldungArticle(String title, String content) {
|
private BaeldungArticle(String title, String content) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String title() {
|
public String title() {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String content() {
|
public String content() {
|
||||||
return this.content;
|
return this.content;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
78
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/BaeldungReader.java
Executable file → Normal file
78
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/BaeldungReader.java
Executable file → Normal file
@ -1,40 +1,40 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BaeldungReader {
|
public class BaeldungReader {
|
||||||
|
|
||||||
private ArticleReader articleReader;
|
private ArticleReader articleReader;
|
||||||
private IArticleWriter articleWriter;
|
private IArticleWriter articleWriter;
|
||||||
|
|
||||||
public BaeldungReader() {
|
public BaeldungReader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
public BaeldungReader(ArticleReader articleReader) {
|
public BaeldungReader(ArticleReader articleReader) {
|
||||||
this.articleReader = articleReader;
|
this.articleReader = articleReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaeldungReader(IArticleWriter writer) {
|
public BaeldungReader(IArticleWriter writer) {
|
||||||
this.articleWriter = writer;
|
this.articleWriter = writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaeldungReader(ArticleReader articleReader, IArticleWriter writer) {
|
public BaeldungReader(ArticleReader articleReader, IArticleWriter writer) {
|
||||||
this.articleReader = articleReader;
|
this.articleReader = articleReader;
|
||||||
this.articleWriter = writer;
|
this.articleWriter = writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaeldungArticle readNext() {
|
public BaeldungArticle readNext() {
|
||||||
return articleReader.next();
|
return articleReader.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaeldungArticle> readTopic(String topic) {
|
public List<BaeldungArticle> readTopic(String topic) {
|
||||||
return articleReader.ofTopic(topic);
|
return articleReader.ofTopic(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String write(String title, String content) {
|
public String write(String title, String content) {
|
||||||
return articleWriter.write(title, content);
|
return articleWriter.write(title, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
12
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/IArticleWriter.java
Executable file → Normal file
12
testing-modules/mocks/mock-comparisons/src/main/java/com/baeldung/easymock/IArticleWriter.java
Executable file → Normal file
@ -1,7 +1,7 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
public interface IArticleWriter {
|
public interface IArticleWriter {
|
||||||
|
|
||||||
String write(String title, String content);
|
String write(String title, String content);
|
||||||
|
|
||||||
}
|
}
|
114
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderAnnotatedUnitTest.java
Executable file → Normal file
114
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderAnnotatedUnitTest.java
Executable file → Normal file
@ -1,57 +1,57 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
import org.easymock.EasyMockRunner;
|
import org.easymock.EasyMockRunner;
|
||||||
import org.easymock.Mock;
|
import org.easymock.Mock;
|
||||||
import org.easymock.TestSubject;
|
import org.easymock.TestSubject;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*;
|
import static org.easymock.EasyMock.*;
|
||||||
|
|
||||||
@RunWith(EasyMockRunner.class)
|
@RunWith(EasyMockRunner.class)
|
||||||
public class BaeldungReaderAnnotatedUnitTest {
|
public class BaeldungReaderAnnotatedUnitTest {
|
||||||
|
|
||||||
@Mock ArticleReader mockArticleReader;
|
@Mock ArticleReader mockArticleReader;
|
||||||
|
|
||||||
@Mock IArticleWriter mockArticleWriter;
|
@Mock IArticleWriter mockArticleWriter;
|
||||||
|
|
||||||
@TestSubject BaeldungReader baeldungReader = new BaeldungReader();
|
@TestSubject BaeldungReader baeldungReader = new BaeldungReader();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenReadNext_thenNextArticleRead() {
|
public void givenBaeldungReader_whenReadNext_thenNextArticleRead() {
|
||||||
expect(mockArticleReader.next()).andReturn(null);
|
expect(mockArticleReader.next()).andReturn(null);
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mock BaeldungReader mockBaeldungReader;
|
@Mock BaeldungReader mockBaeldungReader;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenWrite_thenWriterCalled() {
|
public void givenBaeldungReader_whenWrite_thenWriterCalled() {
|
||||||
expect(mockArticleWriter.write("title", "content")).andReturn(null);
|
expect(mockArticleWriter.write("title", "content")).andReturn(null);
|
||||||
replay(mockArticleWriter);
|
replay(mockArticleWriter);
|
||||||
baeldungReader.write("title", "content");
|
baeldungReader.write("title", "content");
|
||||||
verify(mockArticleWriter);
|
verify(mockArticleWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenArticlesInReader_whenReadTillEnd_thenThrowException() {
|
public void givenArticlesInReader_whenReadTillEnd_thenThrowException() {
|
||||||
expect(mockArticleReader.next())
|
expect(mockArticleReader.next())
|
||||||
.andReturn(null)
|
.andReturn(null)
|
||||||
.times(2)
|
.times(2)
|
||||||
.andThrow(new NoSuchElementException());
|
.andThrow(new NoSuchElementException());
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
114
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderAnnotatedWithRuleUnitTest.java
Executable file → Normal file
114
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderAnnotatedWithRuleUnitTest.java
Executable file → Normal file
@ -1,57 +1,57 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
import org.easymock.EasyMockRule;
|
import org.easymock.EasyMockRule;
|
||||||
import org.easymock.Mock;
|
import org.easymock.Mock;
|
||||||
import org.easymock.TestSubject;
|
import org.easymock.TestSubject;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*;
|
import static org.easymock.EasyMock.*;
|
||||||
|
|
||||||
public class BaeldungReaderAnnotatedWithRuleUnitTest {
|
public class BaeldungReaderAnnotatedWithRuleUnitTest {
|
||||||
|
|
||||||
@Rule public EasyMockRule mockRule = new EasyMockRule(this);
|
@Rule public EasyMockRule mockRule = new EasyMockRule(this);
|
||||||
|
|
||||||
@Mock ArticleReader mockArticleReader;
|
@Mock ArticleReader mockArticleReader;
|
||||||
|
|
||||||
@Mock IArticleWriter mockArticleWriter;
|
@Mock IArticleWriter mockArticleWriter;
|
||||||
|
|
||||||
@TestSubject BaeldungReader baeldungReader = new BaeldungReader();
|
@TestSubject BaeldungReader baeldungReader = new BaeldungReader();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenReadNext_thenNextArticleRead() {
|
public void givenBaeldungReader_whenReadNext_thenNextArticleRead() {
|
||||||
expect(mockArticleReader.next()).andReturn(null);
|
expect(mockArticleReader.next()).andReturn(null);
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mock BaeldungReader mockBaeldungReader;
|
@Mock BaeldungReader mockBaeldungReader;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenWrite_thenWriterCalled() {
|
public void givenBaeldungReader_whenWrite_thenWriterCalled() {
|
||||||
expect(mockArticleWriter.write("title", "content")).andReturn(null);
|
expect(mockArticleWriter.write("title", "content")).andReturn(null);
|
||||||
replay(mockArticleWriter);
|
replay(mockArticleWriter);
|
||||||
baeldungReader.write("title", "content");
|
baeldungReader.write("title", "content");
|
||||||
verify(mockArticleWriter);
|
verify(mockArticleWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenArticlesInReader_whenReadTillEnd_thenThrowException() {
|
public void givenArticlesInReader_whenReadTillEnd_thenThrowException() {
|
||||||
expect(mockArticleReader.next())
|
expect(mockArticleReader.next())
|
||||||
.andReturn(null)
|
.andReturn(null)
|
||||||
.times(2)
|
.times(2)
|
||||||
.andThrow(new NoSuchElementException());
|
.andThrow(new NoSuchElementException());
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderMockDelegationUnitTest.java
Executable file → Normal file
52
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderMockDelegationUnitTest.java
Executable file → Normal file
@ -1,27 +1,27 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
import org.easymock.*;
|
import org.easymock.*;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*;
|
import static org.easymock.EasyMock.*;
|
||||||
|
|
||||||
public class BaeldungReaderMockDelegationUnitTest {
|
public class BaeldungReaderMockDelegationUnitTest {
|
||||||
|
|
||||||
EasyMockSupport easyMockSupport = new EasyMockSupport();
|
EasyMockSupport easyMockSupport = new EasyMockSupport();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenReadAndWriteSequencially_thenWorks() {
|
public void givenBaeldungReader_whenReadAndWriteSequencially_thenWorks() {
|
||||||
ArticleReader mockArticleReader = easyMockSupport.createMock(ArticleReader.class);
|
ArticleReader mockArticleReader = easyMockSupport.createMock(ArticleReader.class);
|
||||||
IArticleWriter mockArticleWriter = easyMockSupport.createMock(IArticleWriter.class);
|
IArticleWriter mockArticleWriter = easyMockSupport.createMock(IArticleWriter.class);
|
||||||
BaeldungReader baeldungReader = new BaeldungReader(mockArticleReader, mockArticleWriter);
|
BaeldungReader baeldungReader = new BaeldungReader(mockArticleReader, mockArticleWriter);
|
||||||
|
|
||||||
expect(mockArticleReader.next()).andReturn(null);
|
expect(mockArticleReader.next()).andReturn(null);
|
||||||
expect(mockArticleWriter.write("title", "content")).andReturn("");
|
expect(mockArticleWriter.write("title", "content")).andReturn("");
|
||||||
easyMockSupport.replayAll();
|
easyMockSupport.replayAll();
|
||||||
|
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
baeldungReader.write("title", "content");
|
baeldungReader.write("title", "content");
|
||||||
easyMockSupport.verifyAll();
|
easyMockSupport.verifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
82
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderMockSupportUnitTest.java
Executable file → Normal file
82
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderMockSupportUnitTest.java
Executable file → Normal file
@ -1,42 +1,42 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
import org.easymock.*;
|
import org.easymock.*;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*;
|
import static org.easymock.EasyMock.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@RunWith(EasyMockRunner.class)
|
@RunWith(EasyMockRunner.class)
|
||||||
public class BaeldungReaderMockSupportUnitTest extends EasyMockSupport {
|
public class BaeldungReaderMockSupportUnitTest extends EasyMockSupport {
|
||||||
|
|
||||||
@TestSubject BaeldungReader baeldungReader = new BaeldungReader();
|
@TestSubject BaeldungReader baeldungReader = new BaeldungReader();
|
||||||
@Mock ArticleReader mockArticleReader;
|
@Mock ArticleReader mockArticleReader;
|
||||||
@Mock IArticleWriter mockArticleWriter;
|
@Mock IArticleWriter mockArticleWriter;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenReadAndWriteSequencially_thenWorks() {
|
public void givenBaeldungReader_whenReadAndWriteSequencially_thenWorks() {
|
||||||
expect(mockArticleReader.next())
|
expect(mockArticleReader.next())
|
||||||
.andReturn(null)
|
.andReturn(null)
|
||||||
.times(2)
|
.times(2)
|
||||||
.andThrow(new NoSuchElementException());
|
.andThrow(new NoSuchElementException());
|
||||||
expect(mockArticleWriter.write("title", "content")).andReturn("BAEL-201801");
|
expect(mockArticleWriter.write("title", "content")).andReturn("BAEL-201801");
|
||||||
replayAll();
|
replayAll();
|
||||||
|
|
||||||
Exception expectedException = null;
|
Exception expectedException = null;
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
expectedException = exception;
|
expectedException = exception;
|
||||||
}
|
}
|
||||||
String articleId = baeldungReader.write("title", "content");
|
String articleId = baeldungReader.write("title", "content");
|
||||||
verifyAll();
|
verifyAll();
|
||||||
assertEquals(NoSuchElementException.class, expectedException.getClass());
|
assertEquals(NoSuchElementException.class, expectedException.getClass());
|
||||||
assertEquals("BAEL-201801", articleId);
|
assertEquals("BAEL-201801", articleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
208
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderUnitTest.java
Executable file → Normal file
208
testing-modules/mocks/mock-comparisons/src/test/java/com/baeldung/easymock/BaeldungReaderUnitTest.java
Executable file → Normal file
@ -1,105 +1,105 @@
|
|||||||
package com.baeldung.easymock;
|
package com.baeldung.easymock;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*;
|
import static org.easymock.EasyMock.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class BaeldungReaderUnitTest {
|
public class BaeldungReaderUnitTest {
|
||||||
|
|
||||||
private BaeldungReader baeldungReader;
|
private BaeldungReader baeldungReader;
|
||||||
|
|
||||||
private ArticleReader mockArticleReader;
|
private ArticleReader mockArticleReader;
|
||||||
|
|
||||||
private IArticleWriter mockArticleWriter;
|
private IArticleWriter mockArticleWriter;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenReadNext_thenNextArticleRead() {
|
public void givenBaeldungReader_whenReadNext_thenNextArticleRead() {
|
||||||
mockArticleReader = mock(ArticleReader.class);
|
mockArticleReader = mock(ArticleReader.class);
|
||||||
baeldungReader = new BaeldungReader(mockArticleReader);
|
baeldungReader = new BaeldungReader(mockArticleReader);
|
||||||
|
|
||||||
expect(mockArticleReader.next()).andReturn(null);
|
expect(mockArticleReader.next()).andReturn(null);
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
|
|
||||||
BaeldungArticle article = baeldungReader.readNext();
|
BaeldungArticle article = baeldungReader.readNext();
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
assertEquals(null, article);
|
assertEquals(null, article);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenReadNextAndSkimTopics_thenAllAllowed() {
|
public void givenBaeldungReader_whenReadNextAndSkimTopics_thenAllAllowed() {
|
||||||
mockArticleReader = strictMock(ArticleReader.class);
|
mockArticleReader = strictMock(ArticleReader.class);
|
||||||
baeldungReader = new BaeldungReader(mockArticleReader);
|
baeldungReader = new BaeldungReader(mockArticleReader);
|
||||||
|
|
||||||
expect(mockArticleReader.next()).andReturn(null);
|
expect(mockArticleReader.next()).andReturn(null);
|
||||||
expect(mockArticleReader.ofTopic("easymock")).andReturn(null);
|
expect(mockArticleReader.ofTopic("easymock")).andReturn(null);
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
|
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
baeldungReader.readTopic("easymock");
|
baeldungReader.readTopic("easymock");
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenReadNextAndOthers_thenAllowed() {
|
public void givenBaeldungReader_whenReadNextAndOthers_thenAllowed() {
|
||||||
mockArticleReader = niceMock(ArticleReader.class);
|
mockArticleReader = niceMock(ArticleReader.class);
|
||||||
baeldungReader = new BaeldungReader(mockArticleReader);
|
baeldungReader = new BaeldungReader(mockArticleReader);
|
||||||
|
|
||||||
expect(mockArticleReader.next()).andReturn(null);
|
expect(mockArticleReader.next()).andReturn(null);
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
|
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
baeldungReader.readTopic("easymock");
|
baeldungReader.readTopic("easymock");
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenWriteMaliciousContent_thenArgumentIllegal() {
|
public void givenBaeldungReader_whenWriteMaliciousContent_thenArgumentIllegal() {
|
||||||
mockArticleWriter = mock(IArticleWriter.class);
|
mockArticleWriter = mock(IArticleWriter.class);
|
||||||
baeldungReader = new BaeldungReader(mockArticleWriter);
|
baeldungReader = new BaeldungReader(mockArticleWriter);
|
||||||
expect(mockArticleWriter.write("easymock", "<body onload=alert('baeldung')>")).andThrow(new IllegalArgumentException());
|
expect(mockArticleWriter.write("easymock", "<body onload=alert('baeldung')>")).andThrow(new IllegalArgumentException());
|
||||||
replay(mockArticleWriter);
|
replay(mockArticleWriter);
|
||||||
|
|
||||||
Exception expectedException = null;
|
Exception expectedException = null;
|
||||||
try {
|
try {
|
||||||
baeldungReader.write("easymock", "<body onload=alert('baeldung')>");
|
baeldungReader.write("easymock", "<body onload=alert('baeldung')>");
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
expectedException = exception;
|
expectedException = exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(mockArticleWriter);
|
verify(mockArticleWriter);
|
||||||
assertEquals(IllegalArgumentException.class, expectedException.getClass());
|
assertEquals(IllegalArgumentException.class, expectedException.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBaeldungReader_whenWrite_thenWriterCalled() {
|
public void givenBaeldungReader_whenWrite_thenWriterCalled() {
|
||||||
mockArticleWriter = mock(IArticleWriter.class);
|
mockArticleWriter = mock(IArticleWriter.class);
|
||||||
baeldungReader = new BaeldungReader(mockArticleWriter);
|
baeldungReader = new BaeldungReader(mockArticleWriter);
|
||||||
expect(mockArticleWriter.write("title", "content")).andReturn(null);
|
expect(mockArticleWriter.write("title", "content")).andReturn(null);
|
||||||
replay(mockArticleWriter);
|
replay(mockArticleWriter);
|
||||||
String articleId = baeldungReader.write("title", "content");
|
String articleId = baeldungReader.write("title", "content");
|
||||||
verify(mockArticleWriter);
|
verify(mockArticleWriter);
|
||||||
assertEquals(null, articleId);
|
assertEquals(null, articleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenArticlesInReader_whenReadTillEnd_thenThrowException() {
|
public void givenArticlesInReader_whenReadTillEnd_thenThrowException() {
|
||||||
ArticleReader mockArticleReader = mock(ArticleReader.class);
|
ArticleReader mockArticleReader = mock(ArticleReader.class);
|
||||||
baeldungReader = new BaeldungReader(mockArticleReader);
|
baeldungReader = new BaeldungReader(mockArticleReader);
|
||||||
expect(mockArticleReader.next())
|
expect(mockArticleReader.next())
|
||||||
.andReturn(null)
|
.andReturn(null)
|
||||||
.times(2)
|
.times(2)
|
||||||
.andThrow(new NoSuchElementException());
|
.andThrow(new NoSuchElementException());
|
||||||
replay(mockArticleReader);
|
replay(mockArticleReader);
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
baeldungReader.readNext();
|
baeldungReader.readNext();
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
verify(mockArticleReader);
|
verify(mockArticleReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
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>
|
||||||
<artifactId>testing-modules</artifactId>
|
<artifactId>testing-libraries</artifactId>
|
||||||
<name>testing-modules</name>
|
<name>testing-libraries</name>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@ -31,7 +31,6 @@
|
|||||||
<module>selenium-junit-testng</module>
|
<module>selenium-junit-testng</module>
|
||||||
<module>spring-testing</module>
|
<module>spring-testing</module>
|
||||||
<module>test-containers</module>
|
<module>test-containers</module>
|
||||||
<module>testing</module>
|
|
||||||
<module>testng</module>
|
<module>testng</module>
|
||||||
<module>junit-5-basics</module>
|
<module>junit-5-basics</module>
|
||||||
<module>easymock</module>
|
<module>easymock</module>
|
||||||
|
@ -1,49 +1,49 @@
|
|||||||
package com.baeldung.restassured;
|
package com.baeldung.restassured;
|
||||||
|
|
||||||
public class Odd {
|
public class Odd {
|
||||||
|
|
||||||
float price;
|
float price;
|
||||||
int status;
|
int status;
|
||||||
float ck;
|
float ck;
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
Odd(float price, int status, float ck, String name) {
|
Odd(float price, int status, float ck, String name) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.ck = ck;
|
this.ck = ck;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPrice() {
|
public float getPrice() {
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrice(float price) {
|
public void setPrice(float price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus() {
|
public int getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(int status) {
|
public void setStatus(int status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getCk() {
|
public float getCk() {
|
||||||
return ck;
|
return ck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCk(float ck) {
|
public void setCk(float ck) {
|
||||||
this.ck = ck;
|
this.ck = ck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
0
testing-modules/selenium-junit-testng/geckodriver.mac
Executable file → Normal file
0
testing-modules/selenium-junit-testng/geckodriver.mac
Executable file → Normal file
@ -1,23 +1,23 @@
|
|||||||
package org.baeldung.reflectiontestutils.repository;
|
package org.baeldung.reflectiontestutils.repository;
|
||||||
|
|
||||||
public class Employee {
|
public class Employee {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String employeeToString() {
|
private String employeeToString() {
|
||||||
return "id: " + getId() + "; name: " + getName();
|
return "id: " + getId() + "; name: " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package org.baeldung.reflectiontestutils.repository;
|
package org.baeldung.reflectiontestutils.repository;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class EmployeeService {
|
public class EmployeeService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HRService hrService;
|
private HRService hrService;
|
||||||
|
|
||||||
public String findEmployeeStatus(Integer employeeId) {
|
public String findEmployeeStatus(Integer employeeId) {
|
||||||
return "Employee " + employeeId + " status: " + hrService.getEmployeeStatus(employeeId);
|
return "Employee " + employeeId + " status: " + hrService.getEmployeeStatus(employeeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package org.baeldung.reflectiontestutils.repository;
|
package org.baeldung.reflectiontestutils.repository;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class HRService {
|
public class HRService {
|
||||||
|
|
||||||
public String getEmployeeStatus(Integer employeeId) {
|
public String getEmployeeStatus(Integer employeeId) {
|
||||||
return "Inactive";
|
return "Inactive";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
package org.baeldung.reflectiontestutils;
|
package org.baeldung.reflectiontestutils;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
import org.baeldung.reflectiontestutils.repository.Employee;
|
import org.baeldung.reflectiontestutils.repository.Employee;
|
||||||
import org.baeldung.reflectiontestutils.repository.EmployeeService;
|
import org.baeldung.reflectiontestutils.repository.EmployeeService;
|
||||||
import org.baeldung.reflectiontestutils.repository.HRService;
|
import org.baeldung.reflectiontestutils.repository.HRService;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.test.util.ReflectionTestUtils;
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class ReflectionTestUtilsUnitTest {
|
public class ReflectionTestUtilsUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNonPublicField_thenReflectionTestUtilsSetField() {
|
public void whenNonPublicField_thenReflectionTestUtilsSetField() {
|
||||||
Employee employee = new Employee();
|
Employee employee = new Employee();
|
||||||
ReflectionTestUtils.setField(employee, "id", 1);
|
ReflectionTestUtils.setField(employee, "id", 1);
|
||||||
assertTrue(employee.getId().equals(1));
|
assertTrue(employee.getId().equals(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNonPublicMethod_thenReflectionTestUtilsInvokeMethod() {
|
public void whenNonPublicMethod_thenReflectionTestUtilsInvokeMethod() {
|
||||||
Employee employee = new Employee();
|
Employee employee = new Employee();
|
||||||
ReflectionTestUtils.setField(employee, "id", 1);
|
ReflectionTestUtils.setField(employee, "id", 1);
|
||||||
employee.setName("Smith, John");
|
employee.setName("Smith, John");
|
||||||
assertTrue(ReflectionTestUtils.invokeMethod(employee, "employeeToString").equals("id: 1; name: Smith, John"));
|
assertTrue(ReflectionTestUtils.invokeMethod(employee, "employeeToString").equals("id: 1; name: Smith, John"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenInjectingMockOfDependency_thenReflectionTestUtilsSetField() {
|
public void whenInjectingMockOfDependency_thenReflectionTestUtilsSetField() {
|
||||||
Employee employee = new Employee();
|
Employee employee = new Employee();
|
||||||
ReflectionTestUtils.setField(employee, "id", 1);
|
ReflectionTestUtils.setField(employee, "id", 1);
|
||||||
employee.setName("Smith, John");
|
employee.setName("Smith, John");
|
||||||
|
|
||||||
HRService hrService = mock(HRService.class);
|
HRService hrService = mock(HRService.class);
|
||||||
when(hrService.getEmployeeStatus(employee.getId())).thenReturn("Active");
|
when(hrService.getEmployeeStatus(employee.getId())).thenReturn("Active");
|
||||||
EmployeeService employeeService = new EmployeeService();
|
EmployeeService employeeService = new EmployeeService();
|
||||||
|
|
||||||
// Inject mock into the private field
|
// Inject mock into the private field
|
||||||
ReflectionTestUtils.setField(employeeService, "hrService", hrService);
|
ReflectionTestUtils.setField(employeeService, "hrService", hrService);
|
||||||
assertEquals("Employee " + employee.getId() + " status: Active", employeeService.findEmployeeStatus(employee.getId()));
|
assertEquals("Employee " + employee.getId() + " status: Active", employeeService.findEmployeeStatus(employee.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
=========
|
|
||||||
|
|
||||||
## Mutation Testing
|
|
||||||
|
|
||||||
### Relevant Articles:
|
|
||||||
- [Mutation Testing with PITest](http://www.baeldung.com/java-mutation-testing-with-pitest)
|
|
||||||
- [Intro to JaCoCo](http://www.baeldung.com/jacoco)
|
|
||||||
- [AssertJ’s Java 8 Features](http://www.baeldung.com/assertJ-java-8-features)
|
|
||||||
- [AssertJ for Guava](http://www.baeldung.com/assertJ-for-guava)
|
|
||||||
- [Introduction to AssertJ](http://www.baeldung.com/introduction-to-assertj)
|
|
||||||
- [Cucumber and Scenario Outline](http://www.baeldung.com/cucumber-scenario-outline)
|
|
||||||
- [Testing with Google Truth](http://www.baeldung.com/google-truth)
|
|
||||||
- [Testing with JGoTesting](http://www.baeldung.com/jgotesting)
|
|
||||||
- [Introduction to JUnitParams](http://www.baeldung.com/junit-params)
|
|
||||||
- [Cucumber Java 8 Support](http://www.baeldung.com/cucumber-java-8-support)
|
|
||||||
- [Introduction to Lambda Behave](http://www.baeldung.com/lambda-behave)
|
|
||||||
- [Introduction to Jukito](http://www.baeldung.com/jukito)
|
|
||||||
- [Custom JUnit 4 Test Runners](http://www.baeldung.com/junit-4-custom-runners)
|
|
||||||
- [Guide to JSpec](http://www.baeldung.com/jspec)
|
|
||||||
- [Custom Assertions with AssertJ](http://www.baeldung.com/assertj-custom-assertion)
|
|
||||||
- [Using Conditions with AssertJ Assertions](http://www.baeldung.com/assertj-conditions)
|
|
||||||
- [A Guide to JavaFaker](https://www.baeldung.com/java-faker)
|
|
||||||
- [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java)
|
|
||||||
- [AssertJ Exception Assertions](http://www.baeldung.com/assertj-exception-assertion)
|
|
@ -1,183 +0,0 @@
|
|||||||
<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>testing</artifactId>
|
|
||||||
<version>0.1-SNAPSHOT</version>
|
|
||||||
<name>testing</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-java</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<relativePath>../../parent-java</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.insightfullogic</groupId>
|
|
||||||
<artifactId>lambda-behave</artifactId>
|
|
||||||
<version>${lambda-behave.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<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>info.cukes</groupId>
|
|
||||||
<artifactId>cucumber-junit</artifactId>
|
|
||||||
<version>${cucumber.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>info.cukes</groupId>
|
|
||||||
<artifactId>cucumber-java</artifactId>
|
|
||||||
<version>${cucumber.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>info.cukes</groupId>
|
|
||||||
<artifactId>cucumber-java8</artifactId>
|
|
||||||
<version>${cucumber.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.pitest</groupId>
|
|
||||||
<artifactId>pitest-parent</artifactId>
|
|
||||||
<version>${pitest.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.truth</groupId>
|
|
||||||
<artifactId>truth</artifactId>
|
|
||||||
<version>${truth.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.truth.extensions</groupId>
|
|
||||||
<artifactId>truth-java8-extension</artifactId>
|
|
||||||
<version>${truth.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>pl.pragmatists</groupId>
|
|
||||||
<artifactId>JUnitParams</artifactId>
|
|
||||||
<version>${jUnitParams.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jgotesting</groupId>
|
|
||||||
<artifactId>jgotesting</artifactId>
|
|
||||||
<version>${jgotesting.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jukito</groupId>
|
|
||||||
<artifactId>jukito</artifactId>
|
|
||||||
<version>${jukito.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.javalite</groupId>
|
|
||||||
<artifactId>javalite-common</artifactId>
|
|
||||||
<version>${javalite.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.javafaker</groupId>
|
|
||||||
<artifactId>javafaker</artifactId>
|
|
||||||
<version>${javafaker.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.pitest</groupId>
|
|
||||||
<artifactId>pitest-maven</artifactId>
|
|
||||||
<version>${pitest.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<targetClasses>
|
|
||||||
<param>com.baeldung.testing.mutation.*</param>
|
|
||||||
</targetClasses>
|
|
||||||
<targetTests>
|
|
||||||
<param>com.baeldung.mutation.test.*</param>
|
|
||||||
</targetTests>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.jacoco</groupId>
|
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
|
||||||
<version>${jacoco.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>prepare-agent</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>report</id>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>report</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>jacoco-check</id>
|
|
||||||
<goals>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<rules>
|
|
||||||
<rule>
|
|
||||||
<element>PACKAGE</element>
|
|
||||||
<limits>
|
|
||||||
<limit>
|
|
||||||
<counter>LINE</counter>
|
|
||||||
<value>COVEREDRATIO</value>
|
|
||||||
<minimum>0</minimum>
|
|
||||||
</limit>
|
|
||||||
</limits>
|
|
||||||
</rule>
|
|
||||||
</rules>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-assertions-generator-maven-plugin</artifactId>
|
|
||||||
<version>${assertj-generator.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<classes>
|
|
||||||
<param>com.baeldung.testing.assertj.custom.Person</param>
|
|
||||||
</classes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<cucumber.version>1.2.5</cucumber.version>
|
|
||||||
<pitest.version>1.1.10</pitest.version>
|
|
||||||
<jacoco.version>0.7.7.201606060606</jacoco.version>
|
|
||||||
<guava.version>21.0</guava.version>
|
|
||||||
<assertj-guava.version>3.1.0</assertj-guava.version>
|
|
||||||
<assertj-core.version>3.9.0</assertj-core.version>
|
|
||||||
<assertj-generator.version>2.1.0</assertj-generator.version>
|
|
||||||
<truth.version>0.32</truth.version>
|
|
||||||
<jUnitParams.version>1.1.0</jUnitParams.version>
|
|
||||||
<jgotesting.version>0.12</jgotesting.version>
|
|
||||||
<javalite.version>1.4.13</javalite.version>
|
|
||||||
<lambda-behave.version>0.4</lambda-behave.version>
|
|
||||||
<assertj-guava.version>3.0.0</assertj-guava.version>
|
|
||||||
<jukito.version>1.5</jukito.version>
|
|
||||||
<javafaker.version>0.15</javafaker.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration>
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
|
||||||
</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
@ -1,48 +1,48 @@
|
|||||||
<?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>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<name>testng</name>
|
<name>testng</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../../</relativePath>
|
<relativePath>../../</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 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>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<testng.version>6.10</testng.version>
|
<testng.version>6.10</testng.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -1,67 +1,67 @@
|
|||||||
package com.baeldung.reports;
|
package com.baeldung.reports;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
import org.testng.ITestListener;
|
import org.testng.ITestListener;
|
||||||
import org.testng.ITestResult;
|
import org.testng.ITestResult;
|
||||||
|
|
||||||
public class CustomisedListener implements ITestListener {
|
public class CustomisedListener implements ITestListener {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger("CUSTOM_LOGS");
|
private static final Logger LOGGER = LoggerFactory.getLogger("CUSTOM_LOGS");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinish(ITestContext context) {
|
public void onFinish(ITestContext context) {
|
||||||
LOGGER.info("PASSED TEST CASES");
|
LOGGER.info("PASSED TEST CASES");
|
||||||
context.getPassedTests()
|
context.getPassedTests()
|
||||||
.getAllResults()
|
.getAllResults()
|
||||||
.forEach(result -> {
|
.forEach(result -> {
|
||||||
LOGGER.info(result.getName());
|
LOGGER.info(result.getName());
|
||||||
});
|
});
|
||||||
LOGGER.info("FAILED TEST CASES");
|
LOGGER.info("FAILED TEST CASES");
|
||||||
context.getFailedTests()
|
context.getFailedTests()
|
||||||
.getAllResults()
|
.getAllResults()
|
||||||
.forEach(result -> {
|
.forEach(result -> {
|
||||||
LOGGER.info(result.getName());
|
LOGGER.info(result.getName());
|
||||||
});
|
});
|
||||||
LOGGER.info("Test completed on: " + context.getEndDate()
|
LOGGER.info("Test completed on: " + context.getEndDate()
|
||||||
.toString());
|
.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
|
||||||
public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) {
|
public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestFailure(ITestResult arg0) {
|
public void onTestFailure(ITestResult arg0) {
|
||||||
LOGGER.info("Failed : " + arg0.getName());
|
LOGGER.info("Failed : " + arg0.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestSkipped(ITestResult arg0) {
|
public void onTestSkipped(ITestResult arg0) {
|
||||||
LOGGER.info("Skipped Test: " + arg0.getName());
|
LOGGER.info("Skipped Test: " + arg0.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestStart(ITestResult arg0) {
|
public void onTestStart(ITestResult arg0) {
|
||||||
LOGGER.info("Testing: " + arg0.getName());
|
LOGGER.info("Testing: " + arg0.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestSuccess(ITestResult arg0) {
|
public void onTestSuccess(ITestResult arg0) {
|
||||||
long timeTaken = ((arg0.getEndMillis() - arg0.getStartMillis()));
|
long timeTaken = ((arg0.getEndMillis() - arg0.getStartMillis()));
|
||||||
LOGGER.info("Tested: " + arg0.getName() + " Time taken:" + timeTaken + " ms");
|
LOGGER.info("Tested: " + arg0.getName() + " Time taken:" + timeTaken + " ms");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,111 +1,111 @@
|
|||||||
package com.baeldung.reports;
|
package com.baeldung.reports;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.testng.*;
|
import org.testng.*;
|
||||||
import org.testng.xml.XmlSuite;
|
import org.testng.xml.XmlSuite;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
public class CustomisedReports implements IReporter {
|
public class CustomisedReports implements IReporter {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CustomisedReports.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CustomisedReports.class);
|
||||||
|
|
||||||
private static final String ROW_TEMPLATE = "<tr class=\"%s\"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>";
|
private static final String ROW_TEMPLATE = "<tr class=\"%s\"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>";
|
||||||
|
|
||||||
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
|
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
|
||||||
String reportTemplate = initReportTemplate();
|
String reportTemplate = initReportTemplate();
|
||||||
|
|
||||||
final String body = suites
|
final String body = suites
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(suiteToResults())
|
.flatMap(suiteToResults())
|
||||||
.collect(Collectors.joining());
|
.collect(Collectors.joining());
|
||||||
|
|
||||||
saveReportTemplate(outputDirectory, reportTemplate.replaceFirst("</tbody>", String.format("%s</tbody>", body)));
|
saveReportTemplate(outputDirectory, reportTemplate.replaceFirst("</tbody>", String.format("%s</tbody>", body)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function<ISuite, Stream<? extends String>> suiteToResults() {
|
private Function<ISuite, Stream<? extends String>> suiteToResults() {
|
||||||
return suite -> suite.getResults().entrySet()
|
return suite -> suite.getResults().entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(resultsToRows(suite));
|
.flatMap(resultsToRows(suite));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function<Map.Entry<String, ISuiteResult>, Stream<? extends String>> resultsToRows(ISuite suite) {
|
private Function<Map.Entry<String, ISuiteResult>, Stream<? extends String>> resultsToRows(ISuite suite) {
|
||||||
return e -> {
|
return e -> {
|
||||||
ITestContext testContext = e.getValue().getTestContext();
|
ITestContext testContext = e.getValue().getTestContext();
|
||||||
|
|
||||||
Set<ITestResult> failedTests = testContext
|
Set<ITestResult> failedTests = testContext
|
||||||
.getFailedTests()
|
.getFailedTests()
|
||||||
.getAllResults();
|
.getAllResults();
|
||||||
Set<ITestResult> passedTests = testContext
|
Set<ITestResult> passedTests = testContext
|
||||||
.getPassedTests()
|
.getPassedTests()
|
||||||
.getAllResults();
|
.getAllResults();
|
||||||
Set<ITestResult> skippedTests = testContext
|
Set<ITestResult> skippedTests = testContext
|
||||||
.getSkippedTests()
|
.getSkippedTests()
|
||||||
.getAllResults();
|
.getAllResults();
|
||||||
|
|
||||||
String suiteName = suite.getName();
|
String suiteName = suite.getName();
|
||||||
|
|
||||||
return Stream
|
return Stream
|
||||||
.of(failedTests, passedTests, skippedTests)
|
.of(failedTests, passedTests, skippedTests)
|
||||||
.flatMap(results -> generateReportRows(e.getKey(), suiteName, results).stream());
|
.flatMap(results -> generateReportRows(e.getKey(), suiteName, results).stream());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> generateReportRows(String testName, String suiteName, Set<ITestResult> allTestResults) {
|
private List<String> generateReportRows(String testName, String suiteName, Set<ITestResult> allTestResults) {
|
||||||
return allTestResults.stream()
|
return allTestResults.stream()
|
||||||
.map(testResultToResultRow(testName, suiteName))
|
.map(testResultToResultRow(testName, suiteName))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function<ITestResult, String> testResultToResultRow(String testName, String suiteName) {
|
private Function<ITestResult, String> testResultToResultRow(String testName, String suiteName) {
|
||||||
return testResult -> {
|
return testResult -> {
|
||||||
switch (testResult.getStatus()) {
|
switch (testResult.getStatus()) {
|
||||||
case ITestResult.FAILURE:
|
case ITestResult.FAILURE:
|
||||||
return String.format(ROW_TEMPLATE, "danger", suiteName, testName, testResult.getName(), "FAILED", "NA");
|
return String.format(ROW_TEMPLATE, "danger", suiteName, testName, testResult.getName(), "FAILED", "NA");
|
||||||
|
|
||||||
case ITestResult.SUCCESS:
|
case ITestResult.SUCCESS:
|
||||||
return String.format(ROW_TEMPLATE, "success", suiteName, testName, testResult.getName(), "PASSED", String.valueOf(testResult.getEndMillis() - testResult.getStartMillis()));
|
return String.format(ROW_TEMPLATE, "success", suiteName, testName, testResult.getName(), "PASSED", String.valueOf(testResult.getEndMillis() - testResult.getStartMillis()));
|
||||||
|
|
||||||
case ITestResult.SKIP:
|
case ITestResult.SKIP:
|
||||||
return String.format(ROW_TEMPLATE, "warning", suiteName, testName, testResult.getName(), "SKIPPED", "NA");
|
return String.format(ROW_TEMPLATE, "warning", suiteName, testName, testResult.getName(), "SKIPPED", "NA");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private String initReportTemplate() {
|
private String initReportTemplate() {
|
||||||
String template = null;
|
String template = null;
|
||||||
byte[] reportTemplate;
|
byte[] reportTemplate;
|
||||||
try {
|
try {
|
||||||
reportTemplate = Files.readAllBytes(Paths.get("src/test/resources/reportTemplate.html"));
|
reportTemplate = Files.readAllBytes(Paths.get("src/test/resources/reportTemplate.html"));
|
||||||
template = new String(reportTemplate, "UTF-8");
|
template = new String(reportTemplate, "UTF-8");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Problem initializing template", e);
|
LOGGER.error("Problem initializing template", e);
|
||||||
}
|
}
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveReportTemplate(String outputDirectory, String reportTemplate) {
|
private void saveReportTemplate(String outputDirectory, String reportTemplate) {
|
||||||
new File(outputDirectory).mkdirs();
|
new File(outputDirectory).mkdirs();
|
||||||
try {
|
try {
|
||||||
PrintWriter reportWriter = new PrintWriter(new BufferedWriter(new FileWriter(new File(outputDirectory, "my-report.html"))));
|
PrintWriter reportWriter = new PrintWriter(new BufferedWriter(new FileWriter(new File(outputDirectory, "my-report.html"))));
|
||||||
reportWriter.println(reportTemplate);
|
reportWriter.println(reportTemplate);
|
||||||
reportWriter.flush();
|
reportWriter.flush();
|
||||||
reportWriter.close();
|
reportWriter.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Problem saving template", e);
|
LOGGER.error("Problem saving template", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>web - %date [%thread] %-5level %logger{36} - %message%n
|
<pattern>web - %date [%thread] %-5level %logger{36} - %message%n
|
||||||
</pattern>
|
</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<logger name="org.springframework" level="WARN" />
|
<logger name="org.springframework" level="WARN" />
|
||||||
<logger name="org.springframework.transaction" level="WARN" />
|
<logger name="org.springframework.transaction" level="WARN" />
|
||||||
|
|
||||||
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
|
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
|
||||||
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
|
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
|
||||||
|
|
||||||
<root level="INFO">
|
<root level="INFO">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</root>
|
</root>
|
||||||
</configuration>
|
</configuration>
|
@ -1,13 +1,13 @@
|
|||||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||||
<suite name="My test suite">
|
<suite name="My test suite">
|
||||||
<listeners>
|
<listeners>
|
||||||
<listener class-name="com.baeldung.reports.CustomisedListener"></listener>
|
<listener class-name="com.baeldung.reports.CustomisedListener"></listener>
|
||||||
</listeners>
|
</listeners>
|
||||||
<test name="numbersXML">
|
<test name="numbersXML">
|
||||||
<parameter name="value" value="1"/>
|
<parameter name="value" value="1"/>
|
||||||
<parameter name="isEven" value="false"/>
|
<parameter name="isEven" value="false"/>
|
||||||
<classes>
|
<classes>
|
||||||
<class name="com.baeldung.ParametrizedLongRunningUnitTest"/>
|
<class name="com.baeldung.ParametrizedLongRunningUnitTest"/>
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
</suite>
|
</suite>
|
@ -1,13 +1,13 @@
|
|||||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||||
<suite name="regression_test">
|
<suite name="regression_test">
|
||||||
<test name="test groups">
|
<test name="test groups">
|
||||||
<groups>
|
<groups>
|
||||||
<run>
|
<run>
|
||||||
<include name="regression"/>
|
<include name="regression"/>
|
||||||
</run>
|
</run>
|
||||||
</groups>
|
</groups>
|
||||||
<classes>
|
<classes>
|
||||||
<class name="com.baeldung.SummationServiceIntegrationTest"/>
|
<class name="com.baeldung.SummationServiceIntegrationTest"/>
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
</suite>
|
</suite>
|
@ -1,17 +1,17 @@
|
|||||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||||
<suite name="regression_test">
|
<suite name="regression_test">
|
||||||
<test name="test setup">
|
<test name="test setup">
|
||||||
<groups>
|
<groups>
|
||||||
<run>
|
<run>
|
||||||
<include name="regression"/>
|
<include name="regression"/>
|
||||||
</run>
|
</run>
|
||||||
</groups>
|
</groups>
|
||||||
<classes>
|
<classes>
|
||||||
<class name="com.baeldung.SummationServiceIntegrationTest">
|
<class name="com.baeldung.SummationServiceIntegrationTest">
|
||||||
<methods>
|
<methods>
|
||||||
<include name="givenNumbers_sumEquals_thenCorrect"/>
|
<include name="givenNumbers_sumEquals_thenCorrect"/>
|
||||||
</methods>
|
</methods>
|
||||||
</class>
|
</class>
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
</suite>
|
</suite>
|
@ -1,13 +1,13 @@
|
|||||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||||
<suite name="suite" parallel="classes" thread-count="2">
|
<suite name="suite" parallel="classes" thread-count="2">
|
||||||
<listeners>
|
<listeners>
|
||||||
<listener class-name="com.baeldung.reports.CustomisedReports" />
|
<listener class-name="com.baeldung.reports.CustomisedReports" />
|
||||||
</listeners>
|
</listeners>
|
||||||
<test name="test suite">
|
<test name="test suite">
|
||||||
<classes>
|
<classes>
|
||||||
<class name="com.baeldung.RegistrationLongRunningUnitTest" />
|
<class name="com.baeldung.RegistrationLongRunningUnitTest" />
|
||||||
<class name="com.baeldung.SignInLongRunningUnitTest" />
|
<class name="com.baeldung.SignInLongRunningUnitTest" />
|
||||||
<class name="com.baeldung.SimpleLongRunningUnitTest" />
|
<class name="com.baeldung.SimpleLongRunningUnitTest" />
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
</suite>
|
</suite>
|
Loading…
x
Reference in New Issue
Block a user