Serenity configuration
Add Serenity .jar files in pom.xml (will download into eclipse IDE)
Creating a project using Serenity –
Cucumber BDD – Maven
The pom file
Issues Facing During Serenity
Configuration
Add Serenity .jar files in pom.xml (will download into eclipse IDE)
-
Serenity – core
-
Serenity – cucumber
-
Serenity -Junit
Code snippet:
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>1.9.31</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>1.9.31</version>
</dependency>
2.1 Add junit .jar files into pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
Add property file – (version of serenity and
web driver)
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>1.0.47</serenity.version>
<serenity.maven.version>1.0.47</serenity.maven.version>
<webdriver.driver>chrome</webdriver.driver>
</properties>
2.1 Add Report generated build files
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<configuration>
<includes>
<include>**/*TestRunner.java</include>
</includes>
<systemProperties>
<webdriver.driver>chrome</webdriver.driver>
<surefire.rerunFailingTestsCount>5</surefire.rerunFailingTestsCount>
<surefire.rerunFailingTestsCount>5</surefire.rerunFailingTestsCount>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>1.0.6</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>core</artifactId>
<version>1.0.47</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Creating a project using Serenity –
Cucumber BDD – Maven
Create a Maven project in Eclipse
Refer Serenity configuration section (pom.xml)
Create the Feature file under the project
Feature folder
-> Filename.feature (will write scenarios)
Copy the Browser .exe files
(IE/Chrome/Safari/Firefox) into project workspace
Create packages and classes (Homepage.java –
URL and BuyerSteps.java – invoke browser and StepDef.java - feature file generated methods) under the
project
Process of execution:
-
Run Feature file as
-
Once feature file runs, will generate the
methods and copy the generated methods into the stepdefinition class.
-
Maven build and maven test
-
Run the Test Runner class
Once successful execution of scrip, the
results will be pass and browser will close
The pom file
Herewith attached the complete
.jar set up
<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>Testserenity</groupId>
<artifactId>Testserenity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Testserenity</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>1.0.47</serenity.version>
<serenity.maven.version>1.0.47</serenity.maven.version>
<webdriver.driver>chrome</webdriver.driver>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-core -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>1.9.31</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-cucumber -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>1.9.31</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<configuration>
<includes>
<include>**/*TestRunner.java</include>
</includes>
<systemProperties>
<webdriver.driver>chrome</webdriver.driver>
<surefire.rerunFailingTestsCount>5</surefire.rerunFailingTestsCount>
<surefire.rerunFailingTestsCount>5</surefire.rerunFailingTestsCount>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>1.0.6</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>core</artifactId>
<version>1.0.47</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Issues Facing During Serenity
Configuration
- While build running the serenity in Eclipse IDE we should make to add serenity cucumber dependency in pom.xml file since we’ve separate serenity cucumber dependency.
- Make sure the Feature folder name same as the name mentioned in the TestRunner class.
- The name of the stepdefinition assigned to glue will be same as the name of the stepdefinition in Test Runner class i.e., @cucumberOptions (feature = “Feature”, Glue = {“stepdefinition”})
- Serenity.properties : Invoking test execution browsers should be mentioned in the serenity.properties file.
- Make sure that browser .exe file should be placed in project work space.
- Whenever we’re updating the any dependencies through pom.xml, make sure that pom file should be cleaned (Run As -> Maven clean => will appear a message successfully build file cleaned) and then pom file should build (Run As -> Maven Build).
- Clean the Project in the project workspace, if we do multiple updates in pom.xml file or serenity.properties file etc.,
No comments:
Post a Comment