I get many comments from the readers to include a post on Jenkins-QTP-Source control integration & issues they are facing while trying to implement Jenkins-QTP console output which this post talks about. In this post, I would like to show how we can configure Jenkins to fetch the automated test scripts from the source control system like SVN/Github & showing the test case details in the Jenkins console. You can use any Source Control System like perforce. The idea is same. Ensure that you have Jenkins plugin is installed.
Sample QTP/UFT Script:
I am going to create a very simple QTP test script as shown below which launches a website in IE and check if an object is present or not. [I have uploaded the script in GitHub. You can download the script and play with it]
GitHub:
- The above sample test scripts have been uploaded here.
- I assume You already have Jenkins installed and a slave is configured.
- Ensure that the Slave is configured with git. Download and install.
- Lets create a simple and freestyle job in Jenkins.
- Lets assume this job accepts some parameter from the user. Example: The environment of the application under test. [Actually the sample script does not do anything with this parameter. I just wanted to show it is possible to pass a parameter].
- Select GitHub in the Source Code Management and update the URL as https://github.com/vinsguru/tag-qtp-jenkins-demo.git
- Build section should have ‘Execute Windows batch command’ and the command should be ‘CScript runner.vbs %ENVIRONMENT%‘
- Jenkins Job is ready to fetch the script from GitHub now. Click on Build to execute the scripts from Jenkins in the Slave machine.
- Jenkins automatically downloads the script from github to the slave machine and executes it on the slave machine. [I assumed Slave has QTP installed].
- It executes the script and shows the test case details being executed in the Jenkins console output and the status.
SVN:
You can also use Visual SVN Server which is FREE if you do not want to share your script in GitHub.
- Download and install from here.
- Once installed, Create a Repository with default branches.
- Create users and provide appropriate access. [For Jenkins, I create a separate user with readonly access]
- Right click on the folder and copy the URL which you can access from any machine.
- VisualSVN Server is ready now which is up and running. We need a SVN client to push the script to the SVN server. We can use TortoiseSVN for this purpose.
- Download and install TortoiseSVN from here.
- Once installed, Create a folder – Right click – Do a SVN Checkout of the URL you have copied.
- Copy all your test scripts under the folder – right click – Do SVN Commit.
- This will push all your test scripts to the Visual SVN Server.
Jenkins-SVN Integration:
- Select Subversion in the Source Code Management. Update the Repository URL to be checked out by Jenkins to run the script.
- If it requires a credential, Add the Credentials. [If you do not see this, there is a Jenkins plugin. Install it in Jenkins]
- Update the Check-out strategy as shown here.
- Credentials Plugin for Jenkins
- Everything else will remain same. Click on Build to run the QTP script.
Happy Testing 🙂