ChainTest Reports can be run on docker (dynamic report).
What is ChainLP?
ChainLP (Chain-Long-Playing like LP Record) is a Java (Spring) server which packs the Angular frontend and is distributed as a Docker image. ChainLP is the framework component providing historical analytics.
The recommended way to run ChainLP is with docker-compose. Currently, the supported databases are listed below but most RDBMS database should work.
H2
MySQL
PostgreSQL
For each database, there is a separate docker-compose.yml available at chainlp/docker. H2 provides the most straight-forward way to test, but it is NOT recommended for production use.
Add the following properties to chaintest.properties file in src/test/resources
# chaintest configuration
chaintest.project.name= ChaninTest Report with Cucumber and TestNG
# generators:
## chainlp
chaintest.generator.chainlp.enabled=true
chaintest.generator.chainlp.class-name=com.aventstack.chaintest.generator.ChainLPGenerator
chaintest.generator.chainlp.host.url=http://localhost/
chaintest.generator.chainlp.client.request-timeout-s=30
chaintest.generator.chainlp.client.expect-continue=false
chaintest.generator.chainlp.client.max-retries=3
Run the test either through command line or through Test Runner class.
Run the tests through command line
To run the tests, use the below command
mvn clean test
Updation of ChainTest Report
ChainTest Report is updated with the current test run as shown below:
Click on the project and it will show the complete test execution report.
Click on cucumber-jvm option. It will show the detailed execution report. This report includes a pie chart for the feature, Scenario and Steps. Here, we have executed 1 feature file and 1 scenario. The Feature file has failed. So, the Feature pie chart shows 100% failed. There are 5 scenarios. Out of 5, 4 tests are passed. 1 test failed. Therefore, the Scenario pie chart shows 80% passed. This report also shows error message for the failed test.
We see that one of the tests has failed. The screenshot of the failed test is also attached in the report.
We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!
In the previous tutorial, will explain ChainTest Report and its implementation with Selenium with TestNG. In this tutorial, we will discuss the steps to add the screenshot for the failed tests in the ChainTest Report.
The chaintest-core client is the framework component that supports plugins to store embeds for each report. For example, with SimpleGenerator, the client saves all embeds relative to the report file in the resources folder.
Starting chaintest-testng plugin 1.0.5+, screenshots can be attached to tests while the test is in-flight or completing in the @BeforeMethod and @AfterMethod hooks.
ExtentReport, one of the most popular and extensively used test reports, has been officially retired due to changes in automated testing techniques. The same developer, Anshoo Arora, fills the void with ChainTest, a potent reporting system. With its enhanced capabilities, real-time data, and seamless integration options, ChainTest is anticipated to transform how we see test results.
ChainTest is a complete reporting system, it supports a variety of sources, including email, static data, and real-time, historical analytics with ChainLP. The next-generation reporting framework ChainTest was developed for a number of test frameworks, such as Cucumber, JUnit, and TestNG.
Key Features of ChainTest Report
Combination of Report – ChainTest generates a combination of static report, email and dynamic report.
Real Time Analysis – ChainTest’s incorporation of real-time statistics allows teams to monitor test executions in real time. This feature is very helpful for extensive testing projects with tight deadlines.
Simple SetUp – Setting up ChainTest is simple and quick with an easily accessible properties file. The setup procedure is streamlined by the ease with which users can specify project names, server URLs, and report options.
Support multiple test framework – This is compatible with a number of test frameworks, such as Cucumber, JUnit, and TestNG. Integration with PyTest is also expected to be available soon.
Docker-Enabled Setup – Docker simplifies the process of setting up ChainTest. The Chain LP server can be spun up in a matter of minutes by users by pulling the Docker image, which streamlines deployment and minimizes system requirements.
Monitoring of Historical Data – The historical data tracking tool, which enables teams to examine performance trends across several builds, is one notable feature. This makes it easier to spot trends and enhance test-taking techniques.
Prerequisite
Java 17 is installed
Maven is installed
Eclipse or IntelliJ is installed
Dependency List:
Selenium – 4.28.1
Java 17
TestNG – 7.10.2
Maven – 3.9.6
ChainTest TestNG – 1.0.7
Structure of Project
Implementation
Add ChainTest TestNG plugin dependency in Maven Project.
Add ChainTestListener in the list of @Listeners of the test class. Here, I have added this to BaseTests class.
@Listeners(ChainTestListener.class)
public class BaseTests {
}
Create a testng.xml at the root directory.
Create a testng.xml at the root of the project. This xml contains parameter detail like allow passing parameters to test methods ie browser name.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="ChainTestReport with TestNG">
<test name="Chrome Test">
<parameter name="browserName" value="chrome" />
<classes>
<class name="com.example.LoginPageTests"/>
</classes>
</test> <!-- Test -->
<test name="Firefox Test">
<parameter name="browserName" value="firefox" />
<classes>
<class name="com.example.LoginPageTests"/>
</classes>
</test> <!-- Test -->
<test name="Edge Test">
<parameter name="browserName" value="edge" />
<classes>
<class name="com.example.LoginPageTests"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Run the tests from testng.xml.
Right click on testng.xml and select Run ‘…\testng.xml’
The execution status looks like as shown below. There are 3 tests and 1 test will fail. These 3 tests are executed in 3 different browsers – Chrome, Firefox and Edge. So, total we are executing 9 tests and out of them 6 passed and 3 failed.
View ChainTest Reports
ChainTest Reports are generated in target folder – Index.html and email.html.
Index.html
Right-click and open with Web Browser.
The index.html has a summary section that displays the summary of the execution. The summary includes the overview of the pass/fail using a pictogram, start time, end time, and pass/fail details of tests as shown in the image below.
Email.html
This report contains the high level summary of the test execution.
Run the tests through command line
To run the tests, use the below command
mvn clean test
We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!