Yazılım testinin kutsal kaynağına hoş geldiniz!

DevOps and Test Automation with Jenkins

Getting Started:

This doc will get you up and running with 4 simple automation tests. It is documented according to the macOS operating system.

1. Postman NewMan API test automation
2. Rest Assured API test automation
3. Jmeter performance test
4. Jenkins Pipeline example with automation

Requirements:


 


 

  • Open macOS Terminal and run this command to install Postman’s command-line helper (Required for Postman Newman API test automation)

npm install -g newman

  • Click Manage Jenkins -> Configure System. On the “Global properties” section, check for “Environment variables” and set it on MacOS ${PATH}:/bin:/usr/local/bin:/usr/bin

 

  • Click Manage Jenkins -> Manage Plugins. Click Available to filter not installed plugins on your Jenkins. You need to select the following plugins, install them and finally restart your Jenkins. Git GitHub Performance TestNG

Postman NewMan API test automation

  1. Click “New Item” on Jenkins Home. Set name as “Postman-Newman-API-Collection” and select “Freestyle Project”

 

2. The job configuration screen will be opened. Check for “GitHub project” and paste this URL “https://github.com/software-testing-bootcamp/rest-assured-testng-java-api-testautomation/

3. On the “Source Code Management” tab, select Git. Set Repository URL as “https://github.com/software-testing-bootcamp/rest-assured-testng-java-api-testautomation.git

4. Set “Branch Specifier” as “*/main”

5. On the Build tab, click the “Add build step” button. Select “Execute Shell” for macOS or Linux.

6. Paste this command and modify the full file path for your downloaded “postman_collection.json” file. Download file from here-> https://github.com/software-testing-bootcamp/rest-assured-testng-java-api-testautomation/blob/main/postman_collection.json

newman run /Users/YOUR-USER/Downloads/postman_collection.json --reporters cli,junit --reporter-junit-export "newman/myreport.xml"

7. Click Save and then the Build Now button. Check the console log for your build.

8. You can Add a Post BUild action to show your tests as Junit tests on Jenkins.

Rest Assured API test automation

  1. Click “New Item” on Jenkins Home. Set name as “rest-assured-testng-java-api-testautomation” and select “Maven Project”
  2. The job configuration screen will be opened. Check for “GitHub project” and paste this URL “https://github.com/software-testing-bootcamp/rest-assured-testng-java-api-testautomation/
  3. On the “Source Code Management” tab, select Git. Set Repository URL as “https://github.com/software-testing-bootcamp/rest-assured-testng-java-api-testautomation.git
  4. Set “Branch Specifier” as “*/main”
  5. On the Post-Build Actions tab, click the “Add post-build action” button. Select “Publish TestNG Results”.
  6. Click Save and then the Build Now button.
  7. Click “Latest Test Result” on your Maven Project and review test results.

 

Jmeter performance test

  1. Click “New Item” on Jenkins Home. Set name as “jmeter-performance-test” and select “Freestyle Project”
  2. The job configuration screen will be opened. Check for “GitHub project” and paste this URL “https://github.com/software-testing-bootcamp/jmeter-performance-test
  3. On the “Source Code Management” tab, select Git. Set Repository URL as “https://github.com/software-testing-bootcamp/jmeter-performance-test.git
  4. Set “Branch Specifier” as “*/main”
  5. On the Build tab, click the “Add build step” button. Select “Execute Shell” for macOS or Linux.
  6. Paste this command and modify the full file path for your downloaded “PerformanceTestScenarios.jmx” file. Download file from here-> https://github.com/software-testing-bootcamp/jmeter-performance-test/blob/main/PerformanceTestScenarios.jmx

cd /Users/YOUR-USERNAME/Downloads/ sh apache-jmeter-5.4.1/bin/jmeter -n -t PerformanceTestScenarios.jmx -l testresults.jtl

7. On the Post-Build Actions tab, click the “Add post-build action” button. Select “Publish Performance test result report”. Set Source data files as “/Users/YOUR-USER/Downloads/testresults.jtl”. Do not forget to change your path on your computer.

8. Click Save and then Build Now button.

9. Click Performance Trend on the left menu of your Freestyle job and check the results.


 

Jenkins Pipeline example with automation

Groovy script (Jenkinsfile) is on this repository and details are on the Youtube video


 

Resources for MacOS:

https://www.jenkins.io/doc/book/installing/macos/

https://plugins.jenkins.io/git/

https://plugins.jenkins.io/github/

https://plugins.jenkins.io/performance/

https://plugins.jenkins.io/testng-plugin/

https://www.jenkins.io/doc/book/using/using-jmeter-with-jenkins/

https://learning.postman.com/docs/running-collections/using-newman-cli/integration-with-jenkins/

 

Youtube Webinar Video:

Özgür Kaya
Düşüncelerinizi görmekten mutluluk duyacağız

Leave a reply

Test Relic
Logo
Register New Account