Skip to main content

Test automation tutorial with Selenium WebDriver part 4: Continuous Integration

Continuous Integration

Setup Git server

  1. Install Java if not installed - https://java.com/en/download/
  2. Install Git server
    1. Download http://dl.bintray.com/gitblit/releases/gitblit-1.8.0.zip and unpack it
    2.  Open new cmd.exe window
    3. Go to unpacked folder:
          example: cd C:\Users\IEUser\Downloads\gitblit-1.8.0
    4. Run command:
          java -jar gitblit.jar --httpPort 80 
    5. Now in your browser open 'http://localhost' you should see running Git server:
  3. Create git remote repository
    1. Login as admin(username: 'admin', password: 'admin')
    2. Click 'repositories'
    3. Click 'new repository'
    4. Fill in repository data
      name: osm-testing
      Access Policy: Restrict Push (Authenticated...
    5. Click 'create'
    6. Now new repository should be created:
    7. Now you need to copy repository URL - click on 'URL' and copy line starting with 'http'
      example: http://admin@localhost/r/osm-testing.git
  4.  Push changes to Git server
    1.  Open 'Git Bash' and configure:
        git config --global user.email "you@example.com"
        git config --global user.name "Your Name"
    2.  Navigate to folder which contains our testing code(Hint: use 'cd' command)
    3. Initialize git local repository:
        git init
    4. Add remote repository:
        git remote add origin <url copied in step 3.7>
        example: git remote add origin http://admin@localhost/r/osm-testing.git
    5. Push all your changes to remote repository(If needed use 'admin' as password):
        git add *
        git commit -m 'Initial commit'
        git push origin master 
    6. Go to 'http://localhost/tree/osm-testing.git' and you should be able to see all our files
       

Setup Jenkins server

  1. Download Jenkins war file:
    https://jenkins.io/download/
    http://mirrors.jenkins.io/war-stable/latest/jenkins.war
  2. Start Jenkins server
    1. Open command line promt(cmd.exe)
    2. Navigate to folder where jenkins.war is located
    3. Start Jenkins server:
         java -jar jenkins.war
       
    4. Remember admin password:
       
  3. Go to Jenkins server - Open 'localhost:8080' in browser
  4. Enter password
  5. Choose 'Install suggested plugins'
  6. Set up admin user
  7. Set proper git.exe path
    1. click 'Manage Jenkins'
    2. click 'Global Tool Configuration'
    3. set 'Path to Git executable' with path to Git: 'C:\Program Files\Git\bin\git.exe' (default location)
    4. Save

Create Jenkins job

  1.  Click 'create new job'
  2.  Enter job name 'osm_test_job'
  3.  choose 'Freestyle project'
  4.  in 'Build Triggers' check 'Poll SCM' and in 'Schedule' type:
      H/5 * * * *
  5.  in 'Source Code Management' choose 'Git' and fill
    'Repository URL' with 'git://localhost/osm-testing.git'
  6. in 'Build' click 'Add build step' and choose 'Execute Windows batch command' and enter:
      easy_selenium_cli.py tests --with-xunit --xunit-file=test_results.xml -b gc 
  7. in 'Post-build Actions' click 'Add post-build action'  and choose 'Publish JUnit test results' in 'Test report XMLs' type 'test_results.xml'
  8. click 'Save'
  9. click 'Build'
  10. After build is finished you should see test results:


Next

Try:
  1. Add new test
  2. Push to git
  3. Check that after 5 mins all tests are executed in CI

Comments

Post a Comment