Saturday, December 27, 2008

Creating a Batch Test

A batch test is a test script that calls other tests. You program a batch test by typing call statement directly into the test window and selecting the Batch Run in Batch Mode option in the Run tab of the General Option dialog box before you execute the test.

A batch test my include programming elements such as loops and decision making statements. Loops enable a batch test to run called tests a specified number of times. Decision making statement such if else and switch condition test execution on the results of a test called previously by the same batch script.

For example,the following batch test executes three tests in succession, then loops back and calls the tests again. The loop specifies that the batch test should call the tests ten times.

for (i=0;i<10;i++)
{
call "c:\\abtests\\open" ();
call "c:\\abtests\\setup" ();
call "c:\\abtests\\save" ();
}

To enable a batch test:

1. Choose Settings->General Options

The General Options dialog box opens

1. Click the Run tab
2. Select the Run in Batch Mode check box.
3. Click Ok to close the General Options dialog box.

Running Batch Tests

You can run a group of tests unattended by creating and executing a single batch test. A batch test is a test script that contains call statements to other tests.It opens and executes each test and saves the test results. A Batch test looks like a regular test that includes call statements.

A test becomes a "Batch Test" when you select the Run in Batch Mode optin in the Run tab of the General Options dialog box before you execute the test. When you run a test in Batch mode, WinRunner suppresses all messages that would ordinarily be displayed during execution, such as a message reporting a bitmap mismatch. WinRunner also suppresses all Pause statements and any halts in execution resulting from run time errors.

By suppressing all messages, WinRunner can run a batch test unattended. This differs from a regular,interactive test run in which messages appear on the screen and prompt you to click a button in order to resume test execution. A batch test enables you to run tests overnight or during off-peak hours,so that you can save time while testing your application. When a batch test run is completed,you can view the results in the Test Results Window. The Window displays the results of all the major events that occurred during the run.

Batch Tests

Batch Test: Imagine that you have revised your application and you want to run old test scripts on the revised product. Instead of running each test individually, by using a batch test you can run any number of tests,leave for lunch, and when you get back,see the results of all your tests on your screens. A batch test looks and behaves like a regular test script, expect for two main differences:

1. It contains Call statement, which open other tests.

During a test run, WinRunner interprets a Call statement, and then open and runs the "called" test. When the called test is done, WinRunner returns to the batch test and continues the run.

2.You choose the Run in Batch Mode option on the Run tab of the General Options dialog box (Settings > General Options) before running the test. This option instructs WinRunner to suppress messages that would otherwise interrupt the test. For example, if WinRunner detects a bitmap mismatch,it does not prompt you to pause the test run.When your review the results of a batch test run, you can see the overall results of the batch test (Pass or Fail),as well as the results of each test called by the batch test.

Tuesday, December 2, 2008

Explain the following WinRunner Commands?

• db_connect - to connect to a database

db_connect(, );

• db_execute_query - to execute a query

db_execute_query ( session_name, SQL, record_number );

[record_number is the out value]

•db_get_field_value - returns the value of a single field in the specified row_index and column in the session_name database session.

db_get_field_value ( session_name, row_index, column );

• db_get_headers - returns the number of column headers in a query and the content of the column headers, concatenated and delimited by tabs.

db_get_headers ( session_name, header_count, header_content );

• db_get_row - returns the content of the row, concatenated and delimited by tabs.

db_get_row ( session_name, row_index, row_content );

• db_write_records - writes the record set into a text file delimited by tabs.

db_write_records ( session_name, output_file [ , headers [ , record_limit ] ] );

• db_get_last_error - returns the last error message of the last ODBC or Data Junction operation in the session_name database session.

db_get_last_error ( session_name, error );

• db_disconnect - disconnects from the database and ends the database session.
db_disconnect ( session_name );

• db_dj_convert - runs the djs_file Data Junction export file. When you run this file, the Data Junction Engine converts data from one spoke (source) to another (target). The optional parameters enable you to override the settings in the Data Junction export file.

db_dj_convert ( djs_file [ , output_file [ , headers [ , record_limit ] ] ] );

How do you create parameterize SQL commands?

• A parameterized query is a query in which at least one of the fields of the WHERE clause is parameterized, i.e., the value of the field is specified by a question mark symbol ( ? ).

For example, the following SQL statement is based on a query on the database in the sample Flight Reservation application:

SELECT Flights.Departure, Flights.Flight_Number, Flights.Day_Of_Week FROM Flights WHERE (Flights.Departure=?) AND (Flights.Day_Of_Week=?)

SELECT defines the columns to include in the query.
FROM specifies the path of the database.

WHERE (optional) specifies the conditions, or filters to use in the query.

Departure is the parameter that represents the departure point of a flight.

Day_Of_Week is the parameter that represents the day of the week of a flight.

• When creating a database checkpoint, you insert a db_check statement into your test script. When you parameterize the SQL statement in your checkpoint, the db_check function has a fourth, optional, argument: the parameter_array argument. A statement similar to the following is inserted into your test script:

db_check("list1.cdl", "dbvf1", NO_LIMIT, dbvf1_params);

The parameter_array argument will contain the values to substitute for the parameters in the parameterized checkpoint.

What do you verify with the database checkpoint default and what command it generates, explain syntax?

• By adding runtime database record checkpoints you can compare the information in your application during a test run with the corresponding record in your database. By adding standard database checkpoints to your test scripts, you can check the contents of databases in different versions of your application.

• When you create database checkpoints, you define a query on your database, and your database checkpoint checks the values contained in the result set. The result set is set of values retrieved from the results of the query.

• You can create runtime database record checkpoints in order to compare the values displayed in your application during the test run with the corresponding values in the database. If the comparison does not meet the success criteria you

• Specify for the checkpoint, the checkpoint fails. You can define a successful runtime database record checkpoint as one where one or more matching records were found, exactly one matching record was found, or where no matching records are found.

• You can create standard database checkpoints to compare the current values of the properties of the result set during the test run to the expected values captured during recording or otherwise set before the test run. If the expected results and the current results do not match, the database checkpoint fails. Standard database checkpoints are useful when the expected results can be established before the test run.

Syntax: db_check(, );

• You can add a runtime database record checkpoint to your test in order to compare information that appears in your application during a test run with the current value(s) in the corresponding record(s) in your database. You add runtime database record checkpoints by running the Runtime Record Checkpoint wizard. When you are finished, the wizard inserts the appropriate db_record_check statement into your script.

Syntax:

db_record_check(ChecklistFileName,SuccessConditions,RecordNumber );

ChecklistFileName: A file created by WinRunner and saved in the test's checklist folder. The file contains information about the data to be captured during the test run and its corresponding field in the database. The file is created based on the information entered in the Runtime Record Verification wizard.

Success Conditions Contains one of the following values:

1. DVR_ONE_OR_MORE_MATCH - The checkpoint passes if one or more matching database records are found.

2. DVR_ONE_MATCH - The checkpoint passes if exactly one matching database record is found.

3. DVR_NO_MATCH - The checkpoint passes if no matching database records are found.
RecordNumber An out parameter returning the number of records in the database.

Monday, December 1, 2008

How WinRunner handles varying window labels?

We can handle varying window labels using regular expressions. WinRunner uses two "hidden" properties in order to use regular expression in an object's physical description. These properties are regexp_label and regexp_MSW_class.

• The regexp_label property is used for windows only. It operates "behind the scenes" to insert a regular expression into a window’s label description.

• The regexp_MSW_class property inserts a regular expression into an object's MSW_class. It is obligatory for all types of windows and for the object class object.

What is the purpose of regexp_label property and regexp_MSW_class property?

• The regexp_label property is used for windows only. It operates "behind the scenes" to insert a regular expression into a window’s label description.

• The regexp_MSW_class property inserts a regular expression into an object's MSW_class. It is obligatory for all types of windows and for the object class object.

What is the purpose of the temp GUI map file? What is the extension of GUI map file?

The GUI Map Editor is been provided with a Find and Show Buttons.

• To find a particular object in the GUI Map file in the application, select the object and click the Show window. This blinks the selected object.

• To find a particular object in a GUI Map file click the Find button, this gives the option to select the object. When the object is selected, if the object has been learned to the GUI Map file it will be focused in the GUI Map file.