Using Jenkins and Ant for Selenium WebDriver test execution in continuous integration

Ant can also be configured to run tests in continuous integration with Jenkins. In this recipe, we will set up Jenkins to run tests with Ant.

Getting ready

Running tests with Jenkins and Ant needs both the tools installed on the machine. Refer to the Using Ant for Selenium WebDriver test execution and Configuring Jenkins for continuous integration recipes to install and configure Ant and Jenkins respectively.

How to do it...

Let's configure Jenkins and Ant to run tests in CI:

  1. Navigate to Jenkins Dashboard (http://localhost:8080 by default) in the browser window.
  2. On Jenkins Dashboard, click on the New Job link to create a CI job.
  3. Enter Selenium Cookbook in the Job name: textbox.
  4. Select the Build a free-style software project radio button, as shown in the following screenshot:
    How to do it...
  5. Click on OK.
  6. A new job will be created with the Selenium Cookbook name.
  7. On the job configuration page, go to the Source Code Management section and select the Subversion radio button.
  8. Enter the URL of your test code in the Repository URL textbox, as shown in the following screenshot. Optionally, Jenkins will ask for Subversion login details. Provide user credentials as configured on your SVN server:
    How to do it...
  9. Go to the Build section. Click on the Add build step button once again and select the Invoke Ant option from the drop-down list.
  10. The Ant version textbox will display Default, as shown in the following screenshot:
    How to do it...
  11. Go to the Post-build Actions section.
  12. Click on the Add post-build action button and select Publish JUnit test result report from the drop-down list.
  13. In the Test report XMLs textbox, enter **/report/*.xml, as shown in the following screenshot:
    How to do it...
  14. Click on the Save button to save the configuration.
  15. Go back to the Jenkins Dashboard page.
  16. Click on the Schedule a Build button to trigger the build. Ant will execute the test. Once the build process is complete, click on the Selenium Cookbook project from the list, as shown in the following screenshot:
    How to do it...

    The project page displays the build history and links to the results, as shown in the following screenshot:

    How to do it...
  17. Click on the Latest Test Result link to view the test results, as shown in the following screenshot:
    How to do it...

Scheduling the build for an automatic execution

  1. Go to the Selenium Cookbook project configuration in Jenkins.
  2. In the Build Triggers section, select the Build periodically checkbox.
  3. Enter 0 22 * * * in the Schedule textbox, as shown in the following screenshot. This will trigger the build process every day at 10 p.m:
    Scheduling the build for an automatic execution
  4. Click on the Save button to save the configurations.

See also

  • The Using Ant for Selenium WebDriver test execution recipe
  • The Configuring Jenkins for continuous integration recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.20.90