Model-based testing (MBT) has emerged as a powerful strategy for maintaining high standards of quality in an efficient and systematic manner. MBT transforms the development process by allowing teams to derive scenarios from models of the system under test. These...
HP Quality Center is a web based test management software which supports both manual and automated testing of UI based applications.
Having an existing HP Quality Center infrastructure, it’s easy to integrate your Ranorex automation since HP Quality Center offers so called VAPI-XP-TESTs as an interface to trigger console based applications.
By compiling a Ranorex Test Suite project, a console application will be built which can be triggered by the mentioned VAPI-XP-TESTs. And, as you might know, by specifying command line arguments when running the Test Suite executable, you can control almost everything within a test suite.
Preparation
It is necessary to have the Ranorex main components – and at least a valid runtime license – installed on the machine you are going to execute Ranorex automation on.
For demonstration purposes, you can simply create a new KeePassTestSuite sample project from the Ranorex Studio start page as shown in following figure and compile it:
To execute the Ranorex Test Suite executable, it’s recommended to create a batch file (e.g. C:TestsExecTestSuite.bat) and define parameters for path, executable, report file name and additional command line arguments.
As it’s easier to attach only one file instead of separate files for the style and the included images of a report to a test run, it’s recommended to use the “zr” command line option to compress the generated report to a single archive.
For further details, have a look at the list of all available command line arguments in the section “Running Tests without Ranorex Studio” in our user guide.
The mentioned batch file should contain following code:
cd %1 %2 /zr /zrf:%3 %4 %5 %6 %7 %8 %9
whereas the arguments are defined as follows:
- %1: The path the Ranorex test suite executable is located at
- %2: The test suite executable
- %3: The name of the generated zipped report file
- %4 – %9: up to 5 additional command line arguments forwarded to the Ranorex test suite executable
This batch file will
- change to the directory specified as first command line argument
- start the executable specified as second command line argument
- with enabling the report compression and defining a zipped report file specified as third command line argument
- and additional command line arguments specified in the remaining command line arguments
VAPI-XP-TEST
Create a VAPI-XP-TEST
To trigger a console app we have to create a new VAPI-XP-Test as described in the following steps:
- Add a new test in the “Test Plan” area:
- Set the test type to “VAPI-XP-TEST:
- Select VBScript as Script language:
- Set “Console Application as test type:
- Enter the batch file location in “Application Executable file” and press the “+” button to add the application call to your script:
- Finish the HP VAPI-XP Wizard:
Add Parameters to specify the Ranorex Automation
As we have four parameters with our batch file, add these four parameters to the new generated VAPI-XP-TEST:
Alter the VAPI-XP-TEST Script
The generated Test Script simply calls the batch file as defined in the “HP VAPI-XP-Test Wizard”.
To forward the values of the parameters and to attach the generated report file alter your test script as you can see in following code listing:
Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun) On Error Resume Next ' clear output window TDOutput.Clear Dim path 'String Dim executable 'String Dim args 'String Dim reportFile 'String Dim cmdLineArgs 'String Dim result 'Integer Dim executed 'Integer If Not Debug Then ' bind parameters to local variables With CurrentTSTest.Params For i = 0 To .Count - 1 If StrComp(Trim(.ParamName(i)), "Path", 1) = 0 Then path = .ParamValue(i) End if If StrComp(Trim(.ParamName(i)), "Executable", 1) = 0 Then executable = .ParamValue(i) End if If StrComp(Trim(.ParamName(i)), "Args", 1) = 0 Then args = .ParamValue(i) End if If StrComp(Trim(.ParamName(i)), "ReportFile", 1) = 0 Then reportFile = .ParamValue(i) End if Next End With ' if Report is not set, use default value If isEmpty(reportFile)Then reportFile = "Report.rxzlog" end if ' check whether parameters are set to a value or not If (path = "" or executable = "") Then TDOutPut.Print "Error: Path and/or Executable are not set!" result = -1 executed = -1 Else cmdLineArgs = chr(34)& path & chr(34) & " " & executable & " " & reportFile & " " & args result = XTools.run("C:TestsExecTestSuite.bat", cmdLineArgs , -1, true) executed = 0 end if ' Add zipped report file as attachment if test script has been executed If executed = 0 Then Set objRunAttach = CurrentRun.Attachments Set newAtt = objRunAttach.AddItem(Null) newAtt.FileName = path & "\" & reportFile TDATT_FILE = 1 newAtt.Type = TDATT_FILE newAtt.Post End If ' handle run-time errors If Err.Number <> 0 Then TDOutput.Print "Run-time error [" & Err.Number & "] : " & Err.Description End If ' update execution status in "Test" mode If result <> 0 Or Err.Number <> 0 Then CurrentRun.Status = "Failed" CurrentTSTest.Status = "Failed" End If Else TDOutput.Print "Debug Mode: As no parameters are set, no Ranorex Automation will be executed!" End If End Sub
Test Set
Create a Test Set executing the VAPI-XP-TEST
After defining the test in the “Test Plan” area, you can create a new test set in the “Test Lab” area which triggers the VAPI-XP-TEST generated before.
To do so, follow the directions below:
- Switch from the “Test Plan” to the “Test Lab” area
- Create a new test set:
- Add the VAPI-XP-TEST created before to your newly created test set by dragging/dropping it into the execution grid:
Set Parameters to trigger the Ranorex Automation
This test set should now execute the test case “TC_AddEntry” of the KeePassTestSuite sample project.
Therefore, open the test instance details by double clicking the test in the execution grid and set the parameters in the execution settings as follows:
- Path: the path the test suite executable is located at
- Executable: “KeePassTestSuite.exe”
- Args: “/tc:TC_AddEntry”
- ReportFile: “Report.rxzlog”
You can add several other test sets executing other test cases, or different run configurations. This can be done by simply setting the command line arguments available for test suite execution forwarded by setting the parameter “Args”.
You can additionally set global parameters via command line arguments as well. In the sample test suite used for demonstration, you can set the execution path of the application under test, using following command line argument:
/pa:"GlobalExecutionPath=..."
You can find a list of all available command line arguments in the section “Running Tests without Ranorex Studio“ in our user guide.
Execute the VAPI-XP-TEST
After setting the parameters you should be able to execute your test:
Within the execution grid you will see the test result:
At the test instance details, which can be opened by double-clicking the test in the execution grid, you can analyze several runs of your test:
By double-clicking a specific run, you will see that a zipped report file has been attached to the run.
It can be opened by double-clicking it:
Conclusion
By adding a simple VAPI-XP-TEST as explained in this blog, you are able to create test sets for every Ranorex Test Suite executable by simply altering the arguments passed to the test suite.
This allows you to execute Ranorex test automation within HP Quality Center.
Please feel free to share your thoughts on this topic in the comment section.
Related Posts:
Model-Based Testing with Ranorex DesignWise
Model-based testing (MBT) has emerged as a powerful strategy for maintaining high standards of quality in an efficient and systematic manner. MBT transforms the development process by allowing teams to derive scenarios from models of the system under test. These...
What Is OCR (Optical Character Recognition)?
Optical character recognition technology (OCR), or text recognition, converts text images into a machine-readable format. In an age of growing need for efficient data extraction and analysis processes, OCR has helped organizations revolutionize how they process and...
Support Corner: API Testing and Simple POST Requests
Ranorex Studio is renowned for its robust no-code capabilities, which allow tests to be automated seamlessly across web, mobile, and desktop applications. Beyond its intuitive recording features, Ranorex Studio allows custom code module creation using C# or VB.NET,...