How to make Jenkins run Selenium WebDriver/TestNG/Java tests automatically on deploy and what has Maven to do with all this? How to make Jenkins run Selenium WebDriver/TestNG/Java tests automatically on deploy and what has Maven to do with all this? selenium selenium

How to make Jenkins run Selenium WebDriver/TestNG/Java tests automatically on deploy and what has Maven to do with all this?


Responses, following your list:
Q1. Install Jenkins (we already have that on our server)
A1. None needed.

Q2. Install plugins for Jenkins (which ones?)
A2. As far as I remember no specific plugin is required just for this purpose. Jenkins should be able to run maven or ant job, it's out of the box.

Q3. Install xvfb so tests are run in a headless browser (how do I specify that in the Java written test?)
A3. In your Java tests you will be specifying the host where the browser should be launched (more technically, the host that runs selenium server). It's normally 'localhost', but for this case it will be different (it is generally not a good idea to run jenkins and selenium on the same box). So, in your java code you indicate that host with xvfb AND with selenium grid (that listens to port 4444 by default). It is also considered some good practice to factor this information out of the code (property files and, further, variables in the pom file, or provided by jenkins).

Q4. Install Maven on computer, jenkins and eclipse, use maven projects.
A4. Maven should be installed on jenkins host (and your local machine, the one you use to develop tests).

Q5. Which part of my project folder from the eclipse workplace should I upload on the server and where? I have a testng.xml file and some classes (which are the acutal tests)
A5. Your code is placed under version control (right?), so you point jenkins to fetch your project (then compile code, compile tests, run tests...). The answer is "at least all code that is needed to compile your tests and run them". Jenkins builds your project from source and test execution is just a phase of this process.

Q6. How do I tell Jenkins to automatically run the Selenium Webdriver tests after deploy, and which file do I point to?
A6. use 'integration-test' phase served by surefire plugin.

Q7. How to get reports - through TestNg or through some Jenkins feature?
A7. Jenkins will display (and distribute, if set up this way) the reports generated by testng.


Even I figure out the same problem, When I started configuring my WebDriver project into Maven project and try to Configure that on jenkins I required to go through many tutorial and post on internet. So i though to write down my own. Let me know if this helps
http://qtp-help.blogspot.in/2013/09/webdriver-with-maven.html


If you want to tell Jenkins run your build every time when you deploy, make the following settings in the Jenkins project

Jenkins Build Settings

In this way you tell Jenkins check the repository for updates every 15 minutes, and if update was found, Jenkins run build automatically. You can change time flexibly as you need.