|Published (Last):||28 January 2012|
|PDF File Size:||13.44 Mb|
|ePub File Size:||16.54 Mb|
|Price:||Free* [*Free Regsitration Required]|
SOAP UI Groovy Automation Framework To Test API Field Data Validation – developerWorks Recipes
If there are numerous data fields in response which are coming from multiple tables based on various conditions it becomes very difficult to verify each field manually without human errors.
All the validation rules and the response fields changes with every request, which makes it tutotial to build a script which can be used to test all the requests.
Groovy Script Test Step | Documentation
In addition to this there are conditional and optional tags and the value in response tags may not always be same as the value in database column. This article will help in developing a generalized groovy framework will be built which can be used to perform data validation of any given request with minimal code changes.
Once above files have been downloaded. This is the groovy step which will govern the entire framework run. It will also include setting up global custom properties and taking data input from excel. Process to build the data input excel has been explained in Step 2. Sample groovy code involved in Executable test step has been explained in detail in Step 3. This will include the request to be tested.
This will include the database connection and SQL query to fetch the required details from the table. Details to form Database Connection through this test step has been further explained in Step 5.
This is the groovy step which will handle the test matching of the response fields with the data obtained from the database. Sample groovy code to perform the Database Verification is explained in Step 6.
Once the sopaui structure is ready then the input excel can be build, which will be specific to the type of request. Executable step will consist of a loop which will run till the end of the Input Excel and perform the data validation for each Customer Identification Number. As the Customer Identification number is set as custom properties as CIN, the same value will be used in the request.
The basic concept of verification step will include fetching all the response values into a sequential array of string. Similarly, response values from the JDBC test step will also be fetched into a sequential array of strings. After creating two arrays, the whitespaces will be removed and trim function will be performed on the array so the arrays will only have non- null values.
Once the modified arrays are ready, sequential matching will be performed and in case groovvy failure the index at which it fails will be stored.
The response of the request will also be printed in the excel. The framework can be reused with any request. No Code change is required.
The framework makes use of test data provided in excel. The excel can be utilized to execute different types of test cases using various type of test data. As the framework can be triggered on single click, it makes it easy for anyone to execute the test and study the response.
SOAP UI Groovy Automation Framework To Test API Field Data Validation
You must be logged in to post a comment. Skip to content United States. Search Search developerWorks Recipes Search. Intermediate This article will depict how groovy script can be used to achieve complete data validation. A basic knowledge of API testing and groovy script is required. Step-by-step Step 1- Tutoriaal Groovy Project Structure The framework will have following structure where one test suite will be created for a project.
And the test case will have four below test steps: Following screen shot shows the groovy test steps hierarchy which has been explained above. Step 2 — Building Input Excel Once the framework structure is ready then the grovy excel can be build, which will be specific to the type of request. The excel will have all the required input parameters which are needed to run the request.
In such case excel will have Customer Identification number as Input. Step 3 — Writing Executable Groovy Step Executable step will consist of a loop which will run till the end of the Input Excel and perform the data validation for each Customer Identification Number.
Sample Groovy Code for Executable: Sample example of REST request: OracleDriver Later form a connection string as: Consider the response of the request mentioned in Step 4 as below: Sample Groovy Code for Verification: Framework Run To run the framework, input excel will be filled with the test data.
Next step is to open the executable groovy step and ttutorial on run. Execution result will be maintained in the Input excel itself. Join The Discussion Cancel reply You must be logged in to post a comment.