Steps to Install Jenkins and configure it to Run Maven with TestNg Selenium
Installation
Step 1) Go to http://jenkins-ci.org/and download correct package for your OS. Install Jenkins.
Step 2) Unzip Jenkins to specified folder. Run exe file as shown in following screenshot:
Step 3) In Jenkins 1.607 Setup window click on Next button.
Step 4) Click on Install button in the end.
Step 5) Once installation is done, navigate to the Jenkins Dashboard (http://localhost:8080 by default) in the browser window.
Step 6) Click on the New Item link to create a CI job.
Step 7) Select the Maven project radio button as shown in the following screenshot:
Using the Build a Maven Project option, Jenkins supports building and testing Maven projects.
Step 6) Click on OK button. A new job with name "WebdriverTest" is created in Jenkins Dashboard.
Step 7) Go to Manage Jenkins => Configure System as shown in the following screenshot.
Step 8) Go to the Build section of new job.
- In the Root POM textbox, enter full path to pom.xmlin
- In Goals and options section, enter "clean test"
Step 9) Click on Apply button.
Step 10) On the WebdriverTest project page, click on the Build Now link.
Maven will build the project. It will then have TestNG execute the test cases.
Step 11) Once the build process is completed, in Jenkins Dashboard click on the WebdriverTest project
Step 12) The WebdriverTest project page displays the build history and links to the results as shown in the following screenshot:
Step 13) Click on the "Latest Test Result" link to view the test results as shown in the following screenshot:
Step 14). Select specific build, and you will see the current status by clicking on "console output".
Scheduling Jenkins for automatic execution.
Scheduling builds(Selenium Tests) is one of the important features of Jenkins where it automatically triggers the build, based on defined criteria. Jenkins provides multiple ways to trigger the build process under the Build Trigger configuration.
For example:
Enter 0 23 * * * in the Schedule textbox as shown in the following screenshot. This will trigger the build process every day at 11 p.m.
Enter 0 23 * * * in the Schedule textbox as shown in the following screenshot. This will trigger the build process every day at 11 p.m.
Using Jenkings without Maven
To run pure TestNg script in Jenkins, enter the following in build
D:>java -cp "Pathtolibfolder\lib\*;Pathtobinfolder\bin" org.testng.TestNG testng.xml
- Click on Save button.
- Note: The actual path of lib and bin folder need to add in above command.
- After saving the command, Jenkins will build project in predefined time, and this command will be run using TestNG.
- Result will be stored in custom report HTML file that can be sent via email with a Jenkin configuration
- Output of the code will be
Benefits of using Jenkins
- Early issue finding – Bug can be detected in early phase of the software development
- Automatic integration – no separate effort required to integrate all changes
- Installer – a deployable system available at any point of development
- Records – part build records maintained
- Support and Plugins: One of the reasons for Jenkin's popularity is the availability of large community support. Also, lots of ready-made plugins are available which help you expand its functionality.
Comments
Post a Comment