Difference between revisions of "Integrating Pega unit tests and scenario tests into build tools and pipelines"

From PegaWiki
Integrating Pega unit tests and scenario tests into build tools and pipelines
Jump to navigation Jump to search
(first cut)
Tag: Visual edit
m (added jenkins pipeline content)
Tag: Visual edit
Line 32: Line 32:
 
Pega Platform provides service to execute Pega unit test cases or test suites in your application and return results in xUnit format  
 
Pega Platform provides service to execute Pega unit test cases or test suites in your application and return results in xUnit format  
  
Service comprises the following information
+
'''''Service comprises the following information'''''
 
* ·        Service name: PegaUnit Rule-Test-Unit-Case pzExecuteTests
 
* ·        Service name: PegaUnit Rule-Test-Unit-Case pzExecuteTests
 
* ·        Service package: PegaUnit
 
* ·        Service package: PegaUnit
 
* ·        Endpoint:http://<yourapplicationURL>/prweb/PRRestService/PegaUnit/Rule-Test-Unit-Case/pzExecuteTests
 
* ·        Endpoint:http://<yourapplicationURL>/prweb/PRRestService/PegaUnit/Rule-Test-Unit-Case/pzExecuteTests
 
''               Add REST dependency to invoke Pega unit rest service from your gradle script like below''
 
''               Add REST dependency to invoke Pega unit rest service from your gradle script like below''
[[File:PegaUnitA.png|left|thumb|651x651px]]
+
[[File:Restgradledependency.png|left|thumb|663x663px]]
  
== Use case examples ==
+
''Create your gradle task by sending request parameters as below''
Provide a business example to help users understand the objective.
+
* Uri: ''' Provide the end point URL of your application'''
 +
* Username: '''Provide the operator name'''
 +
* Password: '''Provide the password'''
 +
* HTTP Method '''as post and''' Content Type '''as XML'''
 +
For Example, to execute Pega unit tests through gradle task[[File:PegaUnitA.png|thumb|651x651px|none]]Note: The above gradle task can be called from Jenkins pipeline as well as standalone gradle build task
  
== Before you begin ==
+
Pega platform also provides another service to execute Pega Units in asynchronous mode. This service returns polling ID as response which can be used to track the execution output by using it with the rest service /pegaunits/execute/{ID}/results
Is it necessary to plan anything in advance, or are external steps using other tools required to achieve the goal? If any specific configuration procedures (how-tos) exist on Pega Community pages, you can link to those assets here by providing the URL.
 
  
== Process/Steps to achieve objective ==
+
'''''Service comprises the following information'''''
What do individuals need to know to achieve the outcome? What do individuals need to know to achieve the outcome? Enter the precise steps to guide the user to achieving the desired outcome. Remember to always state where in the software the user must perform an action, before giving the action.
+
* ·        Service name: pegaunits
 +
* ·        Service package: api
 +
* ·        Endpoint:http://<yourapplicationURL>/prweb/api/v1/pegaunits/execute
  
If “How To…” documents exist for specific configuration procedures please link (using the url) to those assets on the community **
+
=== '''Execution of Pega Scenario tests through gradle build tool''' ===
 +
Pega Platform provides service to execute Pega scenario tests and returns the status code of service
  
== Results ==
+
'''''Service comprises the following information and its query parameters'''''
What do you expect the user to see or be able to do after they complete this design pattern?
+
* ·        Service name: scenariotests
 +
* ·        Service package: api
 +
* ·        Endpoint:http://<yourapplicationURL>/prweb/api/v1/scenariotests/execute
 +
'''''Query Parameters:'''''
 +
* JOB ID: Unique Job ID/Run ID/Build number for the invocation (Used by the Deployment manager to separate runs across deployments, also passed as the run id to cloud providers for tracking)
 +
* Provider:  STANDALONE | CBT | BROWSERSTACK Test service provider to use (or Test service cloud provider).
 +
* ProviderAuthName: Auth name for the test service account
 +
* ProviderAuthKey: Auth key for the test service account
 +
* ProviderURL: Alternate test service provider URL (Optional - Generally used for local selenium hubs).
 +
* Browser: Browser to run the UI tests on.
 +
* BrowserVersion: Browser version to run the UI tests on.
 +
* Platform: OS platform to use.
 +
* PlatformVersion: OS Platform version to use.
 +
* ScreenResolution: Resolution of the test system screen to run the tests on.
 +
* SUTURL: URL of the Pega system under test.
 +
* SUTUserID: Test operator ID from the Pega system under test.
 +
* SUTPassword: Password of the test operator ID from the Pega system under test.
 +
* TestSuiteID: pxInsname of the testsuite to be executed.
 +
''Add REST dependency to invoke pega unit rest service from your gradle script like below''
 +
 
 +
'''<big>dependencies {</big>'''
 +
 
 +
'''<big>classpath group: 'org._10ne.gradle', name: 'rest-gradle-plugin', version: '0.4.2'</big>'''
 +
 
 +
'''<big>}</big>'''
 +
 
 +
'''''Build your service URL like below'''''
 +
 
 +
<nowiki>http://xxx:8080/prweb/api/v1/scenariotests/execute?JobID=1&Provider=STANDALONE&ProviderURL=http://10.225.82.213:5555/wd/hub/&Browser=chrome&BrowserVersion=83.0.4103.39&Platform=XP&SUTURL=http://xxxx:8080/prweb/&SUTUserID=xxx&SUTPassword=xxx&TestSuiteID=xxxxx</nowiki>
 +
 
 +
'''''Create your gradle task by sending request parameters as below'''''
 +
* Uri: ''' Provide the end point URL of your application'''
 +
* Username: '''Provide the operator name'''
 +
* Password: '''Provide the password'''
 +
* HTTP Method '''as post'''
 +
'''<u>Note:</u>''' Before running the service, make sure Provider URL is up and running, look at the references section on how to launch Selenium Grid and Browser stack
 +
 
 +
''Sample gradle task to execute Pega scenario tests''
 +
[[File:Scenariotestgradletask.png|left|thumb|1060x1060px]]
 +
 
 +
== Integrating with Jenkins ==
 +
 
 +
=== '''What is Jenkins?''' ===
 +
Jenkins is an open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.
 +
 
 +
Jenkins is highly used CICD tool, Now will look at how can we execute Pega units from Jenkins pipeline project and Jenkins free style project
 +
 
 +
=== '''Jenkins pipeline configuration''' ===
 +
Calling a gradle task from a Jenkins pipeline configuration
 +
* Open a web browser and navigate to the location of the Jenkins server.
 +
* Create a Jenkins job of type Pipeline
 +
* Create a Jenkins pipeline script file like below to run gradle task from your build.gradle<< you can parameterize the URL, UserName and passwords and pass it from Jenkins file to gradle task >>
 +
[[File:Jenkinspipelinesnippet.png|left|thumb|799x799px]]

Revision as of 08:23, 28 October 2020


Curator Assigned
Request to Publish
Description
Version as of
Application
Capability/Industry Area

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ Please Read Below ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

Enter your content below. Use the basic wiki template that is provided to organize your content. After making your edits, add a summary comment that briefly describes your work, and then click "SAVE". To edit your content later, select the page from your "Watchlist" summary. If you can not find your article, search the design pattern title.

When your content is ready for publishing, next to the "Request to Publish" field above, type "Yes". A Curator then reviews and publishes the content, which might take up to 48 hours.

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ The above text will be removed prior to being published ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

Introduction[edit]

Automated unit testing is a key stage of a continuous development and continuous integration model of application development. With continuous and thorough testing, issues are identified and fixed prior to releasing an application, which improves the application quality. Continuous and Automated unit testing is achieved with help of Build tools like Maven, Gradle etc. and Continuous Integration tools like Jenkins, Bamboo etc..

Integrating with Build tools[edit]

What is Build tool?[edit]

  • ·        Software build tools are used to automate the creation of executable applications from source code
  • ·        They script or automate a variety of tasks, such as downloading dependencies, compiling and packaging code, running tests, and deployment
  • ·        Examples of Build tools: ANT, MAVEN and GRADLE etc.

As gradle is widely used build tool, will look at how to execute Pega units and Pega scenario tests from sample gradle build script

Execution of Pega Units through gradle build tool[edit]

Pega Platform provides service to execute Pega unit test cases or test suites in your application and return results in xUnit format

Service comprises the following information

  • ·        Service name: PegaUnit Rule-Test-Unit-Case pzExecuteTests
  • ·        Service package: PegaUnit
  • ·        Endpoint:http://<yourapplicationURL>/prweb/PRRestService/PegaUnit/Rule-Test-Unit-Case/pzExecuteTests

               Add REST dependency to invoke Pega unit rest service from your gradle script like below

Restgradledependency.png

Create your gradle task by sending request parameters as below

  • Uri:  Provide the end point URL of your application
  • Username: Provide the operator name
  • Password: Provide the password
  • HTTP Method as post and Content Type as XML

For Example, to execute Pega unit tests through gradle task

PegaUnitA.png

Note: The above gradle task can be called from Jenkins pipeline as well as standalone gradle build task

Pega platform also provides another service to execute Pega Units in asynchronous mode. This service returns polling ID as response which can be used to track the execution output by using it with the rest service /pegaunits/execute/{ID}/results

Service comprises the following information

  • ·        Service name: pegaunits
  • ·        Service package: api
  • ·        Endpoint:http://<yourapplicationURL>/prweb/api/v1/pegaunits/execute

Execution of Pega Scenario tests through gradle build tool[edit]

Pega Platform provides service to execute Pega scenario tests and returns the status code of service

Service comprises the following information and its query parameters

  • ·        Service name: scenariotests
  • ·        Service package: api
  • ·        Endpoint:http://<yourapplicationURL>/prweb/api/v1/scenariotests/execute

Query Parameters:

  • JOB ID: Unique Job ID/Run ID/Build number for the invocation (Used by the Deployment manager to separate runs across deployments, also passed as the run id to cloud providers for tracking)
  • Provider: STANDALONE | CBT | BROWSERSTACK Test service provider to use (or Test service cloud provider).
  • ProviderAuthName: Auth name for the test service account
  • ProviderAuthKey: Auth key for the test service account
  • ProviderURL: Alternate test service provider URL (Optional - Generally used for local selenium hubs).
  • Browser: Browser to run the UI tests on.
  • BrowserVersion: Browser version to run the UI tests on.
  • Platform: OS platform to use.
  • PlatformVersion: OS Platform version to use.
  • ScreenResolution: Resolution of the test system screen to run the tests on.
  • SUTURL: URL of the Pega system under test.
  • SUTUserID: Test operator ID from the Pega system under test.
  • SUTPassword: Password of the test operator ID from the Pega system under test.
  • TestSuiteID: pxInsname of the testsuite to be executed.

Add REST dependency to invoke pega unit rest service from your gradle script like below

dependencies {

classpath group: 'org._10ne.gradle', name: 'rest-gradle-plugin', version: '0.4.2'

}

Build your service URL like below

http://xxx:8080/prweb/api/v1/scenariotests/execute?JobID=1&Provider=STANDALONE&ProviderURL=http://10.225.82.213:5555/wd/hub/&Browser=chrome&BrowserVersion=83.0.4103.39&Platform=XP&SUTURL=http://xxxx:8080/prweb/&SUTUserID=xxx&SUTPassword=xxx&TestSuiteID=xxxxx

Create your gradle task by sending request parameters as below

  • Uri:  Provide the end point URL of your application
  • Username: Provide the operator name
  • Password: Provide the password
  • HTTP Method as post

Note: Before running the service, make sure Provider URL is up and running, look at the references section on how to launch Selenium Grid and Browser stack

Sample gradle task to execute Pega scenario tests

Scenariotestgradletask.png

Integrating with Jenkins[edit]

What is Jenkins?[edit]

Jenkins is an open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.

Jenkins is highly used CICD tool, Now will look at how can we execute Pega units from Jenkins pipeline project and Jenkins free style project

Jenkins pipeline configuration[edit]

Calling a gradle task from a Jenkins pipeline configuration

  • Open a web browser and navigate to the location of the Jenkins server.
  • Create a Jenkins job of type Pipeline
  • Create a Jenkins pipeline script file like below to run gradle task from your build.gradle<< you can parameterize the URL, UserName and passwords and pass it from Jenkins file to gradle task >>
Jenkinspipelinesnippet.png