0
votes

I want to run my Selenium Webdriver Maven tests in Jenkins. I've followed the tutorial: https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html and https://www.safaribooksonline.com/library/view/jenkins-the-definitive/9781449311155/ch04s06.html But now, I want to run each of hundreds tests that I've written in Selenium Webdriver with Eclipse.

I use Maven to create testng.xml (where I have my Maven projects to can execute a list of tests in the same execution). I use Eclipse to write Java to create tests in Selenium Webdriver. I use github to import tests.

I show you my github project... I don't know how to access into the different folders to execute each testng.xml files, sorry, I'm pretty new here.

enter image description here

enter image description here

enter image description here

Could anybody help me with this issue?

Thanks so much!!!!

1
If I am reading your question right, you have written TestNG test cases using WebDriver and have kept them in a GitHub repository and now you want to pull those test cases and execute them using Jenkins? - ANIL
That's right!!! - UserMB

1 Answers

0
votes
  1. Create a freestyle Jenkins job and then go to the configuration page of your job and in Source Code Management section add the URL of your Git repo where you have kept your TestNG tests. This will help to bring the tests from the repository to your workspace.

  2. Then go to the Build section and select Execute windows batch script if and then add the following script:

    java -cp ".;/path/to/testng-x.x.x.jar;/path/to/jcommander-x.xx.jar;/path/to/test-classes" org.testng.TestNG /path/to/test.xml

    For Linux use the following script with Execute shell in `Build step:

    cd /path/to/test.xml java -cp "/path/to/testng-x.x.x.jar:/path/to/bin" org.testng.TestNG testng.xml

    Where /bin folder contains the compiled code for the TestNG tests.

  3. Then save the job and run the build to execute TestNG test cases.

Note: You can find the required JAR files inside the .m2 folder.