GherkinUFT   SQL Case Selector


Store your SQL data searches in an easily accessible/editable XML file.

When you want your scripts to be re-runable, and always start from a 'Given' know state, use SQL to find test data with all of the attributes you need. Then give each search a name, and call the SQL by name from your Gherkin features.

Given I search for a test case via "SQL_Selector.XML" and <Inp_CaseName> and <Out_Acc_Num>

This will be translated into a Call to the Function KW_Search_For_A_Test_Case ("SQL_Search_File.XML", "Case_Name", "Out_Acc_Num") to retrieve your test case data.

This does assume that you have setup your database variables and user login info in the system Environment.xml and your connectivity to the database is working OK. 

SQL Selector

Write your SQL query, give it a meaningful name and copy it into a text XML file. Your SQL should aim to return just one field from the dB, ie an account number that you can use. If you require multiple data returned, you will need to get your QA Engineer to write you a bespoke function, or use individual SQL lookup's as detailed below.

Now wrap the SQL within a start and end pair   <Variable><Name> Your-Test-Case-Name </Name></Variable>  and you are all set.

This can then be called with above Gherkin-Like syntax Given I search for a test case.....to find you good test data for your scenario.

SQL Functions

This main function requires 3 parameters,..

1. the name of the XML file in the \SQL folder

2. the Case-Name reference used to find the SQL

3. the output location for the SQL result. This output can be sent to either the <Global> sheet, to an "%Environment-Variable" or to the [Output]sheet.

Further functions are used to retrieve the SQL query block from the Case_Selector .xml, and then to actually execute the SQL and retrieve the data.


SQL Case Selector

With your test data for your feature identified and the SQL constructed and placed into the Case-Selector .xml file. You can then use the GherkinUFT vb functions to retrieve the SQL query via  KW_Search_For_A_Test_Case and then execute the query.



     Individual SQL lookups

If you need several data items returned from a database, you can use the single sql syntax to be executed multiple times eg

I search for some SQL data select "xyfield" from "dbname" where "status" equals "credit" output <id1>

I search for some SQL data select "zzfield" from "dbname" where "status" equals "credit" output <id2>

Or you can use the function that returns an array of several fields (info to follow). 


<<<<< Back to Data Chaining                                                                                     Forward to REST APIs >>>>>