Software Testing Material

A site for software testers. We provide free online tutorials on Manual Testing, Automation Testing - Selenium, QTP, LoadRunner, Testing Tools and many more.

  • Blog
  • Tutorials
    • Manual Testing
    • Java
    • Selenium
      • TestNG
      • Maven
      • Jenkins
    • Framework
    • Katalon
    • Agile
    • SQL
    • VBScript
    • API Testing
  • Tools
    • TestLodge
    • FrogLogic GUI Tool
    • CrossBrowserTesting
    • BrowserStack
    • TestCaseLab
    • Kobiton
    • Sikuli
    • Postman
  • Interview Q & A
    • Selenium
    • TestNG
    • Test Framework
    • Explain Framework
    • Manual Testing
    • Software QA
    • Agile
    • Testing As A Career
    • General Interview Questions
    • API Testing
    • SOAP
  • Free Resources
  • Guest Post
    • Guest Post Guidelines
  • Training

How To Execute TestNG Tests Using Jenkins | Software Testing Material

Last Updated on August 10, 2017 by Rajkumar

In the earlier post, we have seen How To Run TestNG Scripts (testng.xml) Using Command Prompt and Using Batch file (.bat). In this post, we see how to execute TestNG Tests Using Jenkins. To do this, we need to have the following

i. TestNG Project
ii. Jenkins – Check this post on Installation of Jenkins.

Don’t Miss: Selenium Complete Tutorial

How To Execute TestNG Tests Using Jenkins

Let’s get started on How To Create TestNG Project.

Step 1: Creating TestNG Project. Follow this link to create TestNG Project.

Must Read: TestNG Complete Tutorial

Step 2: Installing Jenkins. Follow this link for Installing Jenkins

We have TestNG Project and Jenkins ready. Now, lets execute TestNG Tests Using Jenkins.

In the below image, you could see the project structure and testng.xml

Open Jenkins. By default it will be ‘localhost/8080’

Click on ‘New Item’

Enter an Item Name of your preference. I gave the name as ‘TestNGProject‘. In the screenshot below, you could see the name as MavenProject (ignore it).

Select ‘Freestyle Project’ and click on OK button

Now, click on item ‘TestNGProject’

Under General Tab, you could see ‘TestNGProject‘. Click on ‘Advanced‘ button to add the custom workspace.

Now select the ‘Use Custom Workspace‘ checkbox and enter the path of your workspace. My workspace is available at this location ‘D:\DeleteNow\TestNGProject‘

Scroll down to ‘Build‘ option. Click on ‘Add Build Step‘ and choose the value ‘Execute Windows batch command‘ from the drop down list.

My batch file name is ‘BatchRun.bat’ and I specified the same here.

Click on ‘Apply‘ and ‘Save‘

We have created a new project ‘TestNGProject‘ with the configuration to run TestNG Tests using Jenkins. You could see in the below screenshot.

Let’s execute it now. Click on ‘Build Now‘ button. It will invoke testng.xml from the batch file.

Right click on Build Number (here in my case it is #1) and click on Console Output to see the result.

You could see the print statement ‘softwaretestingmaterial.com’ and Build Status ‘Success’

This way, we could execute TestNG Tests using Jenkins. In the next post, we see how to generate TestNG Reports after the completion of execution. Same way, we could execute Maven Project Using Jenkins.

SUBSCRIBE TO GET FREE EBOOK AND REGULAR UPDATES ON SOFTWARE TESTING

Filed Under: Jenkins, Selenium, TestNG

data-matched-content-rows-num="2" data-matched-content-columns-num="3"
Previous Article:
How To Download And Install Jenkins | Software Testing Material
Next Article:
Generate TestNG Reports Using Jenkins | Software Testing Material

About the Author

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Comments

  1. Srinivas says

    August 19, 2017 at 10:11 am

    Hi Rajkumar,
    Thanks for the post. But you didn’t mention how to create “BatchRun.bat” file

    • Rajkumar says

      August 19, 2017 at 4:53 pm

      Hi Srinnivas, Welcome. I have placed a link in the post. Any way, here is the link for you click here on how to create batch file (.bat)

  2. roney says

    November 1, 2017 at 12:00 pm

    Hello sir,
    I just want to know that, I am facing an issue after creating batch file. so my question is that, for creating batch file to run testNG is it neccessary to ad mozilla driver?

    • Rajkumar says

      November 1, 2017 at 12:55 pm

      Hi Roney, in this post you could find how to create batch file.

      FYKI: In the batch file, we don’t pass any driver info.

      • roney says

        November 1, 2017 at 1:55 pm

        no sir. i am not passing any driver info in batch file. but in my script i am passing driver info for chrome. so its not excute the script. thats why i am asking you that is it necessary to pass only gecko driver?

      • roney says

        November 1, 2017 at 1:57 pm

        My batch file is not running properly and not showing any GUI

        • Rajkumar says

          November 1, 2017 at 4:29 pm

          If you are using chrome,
          System.setProperty("webdriver.chrome.driver",path of executable file "Chromedriver.exe")
          Here is the link

          • roney says

            November 2, 2017 at 4:18 am

            yes with the help of this driver i can run my script in eclipse properly.. But its not work after executing batch file.

          • roney says

            November 2, 2017 at 11:22 am

            ok i have done it. i think batch file is only supported to firefox browser..

          • Rajkumar says

            November 3, 2017 at 3:24 am

            Fine Roney. It supports chrome too.

  3. Akado says

    December 5, 2017 at 10:58 am

    Many Thanks for your fantastic Guides in all issues

    • Rajkumar says

      December 6, 2017 at 1:53 am

      Thanks for your kind words Akado

  4. Sandeep says

    December 11, 2017 at 9:18 am

    Hi Rajkumar,

    Please help me with this question. I am getting Configuration failure:1

    https://stackoverflow.com/questions/47679141/configuration-failures-1-skips-1

    • Rajkumar says

      December 11, 2017 at 10:15 am

      Hi whats the value you are passing in your xml file. Share your xml file

      • Sandeep says

        December 11, 2017 at 10:57 am

        Thank you for responding!

        This is my xml file:

        • Sandeep says

          December 11, 2017 at 10:57 am

        • Rajkumar says

          December 11, 2017 at 10:58 am

          Post without < and > replace it with ?

  5. Sandeep says

    December 11, 2017 at 10:59 am

    I have added XML in my question:

    https://stackoverflow.com/questions/47679141/configuration-failures-1-skips-1

  6. Sandeep says

    December 11, 2017 at 11:00 am

    ?xml version=”1.0″ encoding=”UTF-8″?

  7. Sandeep says

    December 11, 2017 at 11:01 am

    ?xml version=”1.0″ encoding=”UTF-8″?
    !DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”
    suite name=”Suite”

    test name=”FirefoxTest”
    parameter name=”browser” value=”Firefox”>

    /suite

  8. Sandeep says

    December 11, 2017 at 11:05 am

    ?xml version=”1.0″ encoding=”UTF-8″?
    !DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”
    suite name=”Suite”

    test name=”FirefoxTest”
    parameter name=”browser” value=”Firefox” parameter
    classes
    class name=”scripts.testJenkins”
    classes
    test

    suite

  9. Sandeep says

    December 11, 2017 at 11:06 am

    I managed to post the XML here!

    • Rajkumar says

      December 11, 2017 at 11:16 am

      Hi Sandeep,
      I have posted answer here

  10. Md Wasim Ansari says

    April 4, 2018 at 9:13 am

    Hi,

    I am unable to run batch i am facing total test run:0 skip:0 issue while trying to run the testng.xml file in CMD.

ADVERTISEMENT

Froglogic-Squish-GUI-Tester
CrossBrowserTesting

TUTORIALS

  • Manual Testing Tutorial
  • Selenium Tutorial
  • TestNG Tutorial
  • VBScript Tutorial
  • Agile Methodology
  • SQL Tutorial for Testers
  • INTERVIEW QUESTIONS

  • Framework Interview Questions
  • Real Time Manual Testing
  • 100 Top Selenium Interview Questions
  • 30 Top TestNG Interview Questions
  • Agile Interview Questions
  • 80 SQL Interview Questions
  • TESTING TOOLS

  • Test Lodge
  • FrogLogic Squish
  • Cross Browser Testing
  • BrowserStack
  • Test Case Lab
  • Sikuli
  • © 2019 www.softwaretestingmaterial.com | About us | Privacy Policy | Contact us | Guest Post | Disclaimer | Terms of use | Sitemap