34

I've been researching this for a good few hours now, but I've only found pieces of the big picture. Everywhere they are assuming that the reader already has a part of the system set up.

I think it will be useful to have a big picture description of the parts needed to put the whole thing together.

They all say "use your maven selenium tests" and so on and so forth.

EDIT: After some research I found out I need to install Maven in Jenkins and on my computer, install a maven plugin for Eclipse, and create/convert my projects as Maven projects. How do I transfer my Maven projects in Jenkins? Do I export to .jar, or do I move the whole folder on the server? How do I connect the whole thing together with xvfb?

So here is what I know so far

  1. Install Jenkins (we already have that on our server)
  2. Install plugins for Jenkins (which ones?)
  3. Install xvfb so tests are run in a headless browser (how do I specify that in the Java written test?)
  4. Install Maven on computer, jenkins and eclipse, use maven projects.
  5. 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)
  6. How do I tell Jenkins to automatically run the Selenium Webdriver tests after deploy, and which file do I point to?
  7. How to get reports - through TestNg or through some Jenkins feature?
James Dunn
  • 8,064
  • 13
  • 53
  • 87
Kaloyan Roussev
  • 14,515
  • 21
  • 98
  • 180

3 Answers3

12

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.

user487772
  • 8,800
  • 5
  • 47
  • 72
patrungel
  • 843
  • 8
  • 13
  • Thank you for your input! 2. Shouldnt I install testng plugin in Jenkins if Im using testng with WebDriver? 3. In my Java code I haven't specified servers, nor ports, here is what I've specified: ` ProfilesIni profile = new ProfilesIni(); FirefoxProfile ffprofile = profile.getProfile("SELENIUM"); driver = new FirefoxDriver(ffprofile);` Should I add something here about hosts and ports, and if "yes" - what exactly? 5. I don't know what "version control" is :(. My code is placed in a workspace folder called "testingMyApp" and there all the files are. Its on my c drive – Kaloyan Roussev Jul 18 '13 at 12:37
  • 6. what is this phase and what is the surefire plugin? – Kaloyan Roussev Jul 18 '13 at 12:37
  • 2. The plugin is for plotting the test result graphs, not for actual test execution, not a must then. 3. http://docs.seleniumhq.org/docs/03_webdriver.jsp WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com"); 5. That's bad, you'd rather start reading. use 'git' and 'subversion' as keywords. 6. Same suggestion re maven-surefire-plugin. Quick googling returned http://176.34.122.30/blog/2008/09/17/automated-integration-testing-with-selenium-maven-and-jetty/ , it looks like providing some good maven xml for surefire+selenium. – patrungel Jul 19 '13 at 08:23
  • so do I have to install the surefire plugin or is it included in maven installation? Then, I use the integration-test phase as a specification in the POM? How do I know which version of testng Im using so I specify that correctly in the POM? Do I upload the source code on the server with jenkins or at some other location? – Kaloyan Roussev Jul 22 '13 at 08:51
  • 1
    maven downloads plugins when you declare them in your pom; same with the version of TestNG: you specify TestNG as dependency and specify version you need. It will be downloaded and used. As for upload, the answer is: 'when setting up a job for Jenkins, indicate the location of the source code'. It can be just some local folder, so you can upload your source code to jenkins. Still it's ill-advised. Why wouldn't you try smaller steps: first get your project compiled by invoking maven from commandline, then have your tests running (mvn again), then move to source control and then to jenkins? – patrungel Jul 22 '13 at 09:47
  • I have same set up.Test cases are running perfectly on Local machine but on server it is throws error "Not able to detect display" on local host for firefox driver(). Any solution of this? – Sagar007 Jan 06 '15 at 06:43
5

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

Gaurang Shah
  • 11,764
  • 9
  • 74
  • 137
0

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.

MSeifert
  • 145,886
  • 38
  • 333
  • 352