Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Jenkins+TestNG for Automation implementation

Shulou Source: shulou.com Published: 2022-06-03 07:10:51 11月23日 Update

Some time ago, I wanted to achieve the goal of continuous integration and continuous testing through Jenkins+testNG! Not only automatically trigger the test and send the results to the relevant personnel, but also track each test result and form a detailed report!

There are three main steps:

1. Write testNG test class and create testng.xml file; trigger test execution manually; make sure the code is correct!

2. Add the maven-surefire-plugin to the pom.xml file, and configure the testng.xml file manually executed into the plugin, as shown in the following figure (demo.xml in the figure)

org.apache.maven.plugins maven-surefire-plugin src/main/java/Demo.xml 2.4

3. You can configure each item in JENKINS

There are two configurations:

1) The system under test and the test code are under one project, i.e. one under/src/main/java and one under/src/test/java; then configure a job

2) The system under test and the test code are not under the same project, so each of the two projects is configured with a job. The job of the test project depends on the job of the system under test. Then, the trigger mechanism is configured under the job of the system under test to check SVN changes.

As shown below:

Configure post-build actions:

See plugin description for specific parameters; this plugin is responsible for reading testng execution results to generate the following test report:

Install the E-mail Notification plug-in and configure the mail template as shown below:

Tags: Testing configuration plug-ins engineering systems code files results manual reports mail three below two personnel available at the same time situation way time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Xiaomi Microsoft Shulou Tech Info