Sunday, October 31, 2010

Risk Based Testing

Risk Based Testing:

Due to less time is available for testing, we are force to reduce the cycle time. In that case, we perform Risk based testing. We categories our test cases based as follows:

  1. Which functionality is most important to project?
  2. Which functionality is most visible to user?
  3. Which functionality has largest impact on users?
  4. Which aspects of the application are most important to the customer?
  5. Which aspects of the application are tested early in the development cycle?

Risk Analysis

Risk Analysis:

A risk is a potential for loss or damage to an Organization from materialized threats. Risk Analysis attempts to identify all the risks and then quantify the severity of the risks. A threat as we have seen is a possible damaging event. If it occurs, it exploits vulnerability in the security of a computer based system.

Risk Identification:
  1. Software Risks: Knowledge of the most common risks associated with Software development, and the platform you are working on. 
  1. Business Risks: Most common risks associated with the business using the software 
  1. Testing Risks: Knowledge of the most common risks associated with Software testing for the platform you are working on, tools being used, and test methods being applied. 
  1. Premature Release Risk: Ability to determine the risk associated with releasing unsatisfactory or untested Software Products. 
  1. Risk Methods: Strategies and approaches for identifying risks or problems associated with implementing and operating information technology, products and process; assessing their likelihood, and initiating strategies to test those risks.

Black Box Testing Technique

Black Box Testing:
Black box testing attempts to derive sets of inputs that will fully exercise all the functional requirements of a system. It is not an alternative to white box testing. This type of testing attempts to find errors in the following categories:

1. Incorrect or missing functions,
2. Interface errors,
3. Errors in data structures or external database access,
4. Performance errors
5. Initialization and termination errors.

Tests are designed to answer the following questions:

1. how is the function's validity tested?
2. What classes of input will make good test cases?
3. Is the system particularly sensitive to certain input values?
4. How are the boundaries of a data class isolated?
5. What data rates and data volume can the system tolerate?
6. What effect will specific combinations of data have on system operation?

White box testing should be performed early in the testing process, while black box testing tends to be applied during later stages. Test cases should be derived which
·         Reduce the number of additional test cases that must be designed to achieve reasonable testing
·         Tell us something about the presence or absence of classes of errors, rather than an error associated only with the specific test at hand.

Testing Technique:

1. Equivalence Partitioning
This method divides the input domain of a program into classes of data from which test cases can be derived. Equivalence partitioning strives to define a test case that uncovers classes of errors and thereby reduces the number of test cases needed. It is based on an evaluation of equivalence classes for an input condition. An equivalence class represents a set of valid or invalid states for input conditions.

Equivalence classes guidelines:
·         If an input condition specifies a range, one valid and two invalid equivalence classes are defined.
·         If an input condition requires a specific value, then one valid and two invalid equivalence classes are defined.
·         If an input condition specifies a member of a set, then one valid and one invalid equivalence classes are defined.
·         If an input condition is Boolean, then one valid and one invalid equivalence classes are defined.

Equivalence Class:
A group of tests form an equivalence class if
·         They all test the same thing
·         If one test reveals a fault, the other ones ( Probably) will too
·         If a test does not reveal a fault, the other ones (probably) will not either.

What goes in equivalence? 
·         There must be a good reason to group tests in one equivalence class
·         They involve the same input variable
·         The result in Similar ( identical?) operations in the program
·         They affect the same output variable
·         None force the program to do error handling, or all of them do.

2. Boundary Value Analysis
This method leads to a selection of test cases that exercise boundary values. It complements equivalence partitioning since it selects test cases at the edges of a class. Rather than focusing on input conditions solely, BVA derives test cases from the output domain also. BVA guidelines include:
      i.        For input ranges bounded by a and b, test cases should include values a and b and just above and just below a and b respectively.
     ii.        If an input condition specifies a number of values, test cases should be developed to exercise the minimum and maximum numbers and values just above and below these limits.
    iii.        Apply guidelines 1 and 2 to the output
   iv.        If internal data structures have prescribed boundaries, a test case should be designed to exercise the data structure at its boundary.

3. Cause-Effect Graphing Techniques:
Cause-effect graphing is a technique that provides a concise representation of logical conditions and corresponding actions. There are four steps:
·         Causes (input conditions) and effects (actions) are listed for a module and an identifier is assigned to each
·         A cause-effect graph is developed.
·         The graph is converted to a decision table.
·         Decision table rules are converted to test cases.

System Test Coverage Strategies Approach

System Test Coverage Strategies Approach:

  1. Major features first. Create tests which will exercise all the principal features first, to give maximum coverage. This will probably be the same as the regression test. Then exercise each feature in some depth. 
  1. Major use cases first. Major features require that you know both the user profile and the use profile. The test must be end-to-end such that some real-world user objective is reached. 
  1. Major inputs and outputs. If the application is I/O dominated, then identify the most common kinds of inputs and outputs and create tests to exercise them. 
  1. All GUI features 
  1. All functions with variations 
  1. All input/output combination

Saturday, October 30, 2010

Check points in QTP

1. What is a Checkpoint?
QTP enables you to add checks to your test. A checkpoint is a verification point that compares a current value for a specified property with the expected value for that property. This enables us to identify whether our Web site or application is functioning correctly.

When you add a checkpoint, QTP adds a checkpoint to the current row in the Keyword View and adds a Check Checkpoint statement in the Expert View. By default, the checkpoint name receives the name of the test object on which the checkpoint is being performed. You can choose to specify a different name for the checkpoint or accept the default name.

When you run the test, QTP compares the expected results of the checkpoint to the current results. If the results do not match, the checkpoint fails. You can view the results of the checkpoint in the Test Results window.

Tip: You can also use the CheckProperty method and the CheckItemProperty method to check specific property or item property values.

2. What is a Bitmap Check Point in QTP?
You can check an area of a Web page or application as a bitmap. While creating a test, you specify the area you want to check by selecting an object. You can check an entire object or any area within an object. QTP captures the visible part of the specified object as a bitmap (QTP does not capture any part that is scrolled off of the screen, for example), and inserts a checkpoint in the test. You can choose to save the entire object with your test, or you can choose to save only the selected area of the object with your test to save disk space.

When you run the test, QTP compares the object or selected area of the object currently displayed on the Web page or application with the bitmap stored when the test was recorded. If there are differences, QTP captures a bitmap of the actual object and displays it with the expected bitmap in the details portion of the Test Results window. By comparing the two bitmaps (expected and actual), you can identify the nature of the discrepancy.

To create a bitmap checkpoint while recording:

1. Choose Insert > Checkpoint > Bitmap Checkpoint, or click the Insert Checkpoint or Output Value button and choose Bitmap Checkpoint.
The QTP window is hidden, and the pointer turns into a pointing hand.

Note: If the object you want to check can only be displayed by performing an event (such as such as right-clicking or moving the pointer over an object to display a context menu), hold the left CTRL key. The pointing hand temporarily turns into a standard pointer and you can perform the event. When the object you want to check is displayed, release the left CTRL key.

The pointer becomes a pointing hand again. You can also use the left CTRL key to change the window focus. Additionally, if the window containing the object you want to select is minimized, you can display it by holding the left CTRL key, right-clicking the application in the Windows task bar, and choosing Restore from the context menu.


2. Click an object to check in your Web page or application.

3. What is a Database Check Point in QTP?
You can use database checkpoints in your test to check databases accessed by your Web site or application, and to detect defects. To do this, you define a query on your database. Then you create a database checkpoint that checks the results of the query.

You can define a database query in the following ways:
• Using Microsoft Query. You can install Microsoft Query from the custom installation of Microsoft Office.
• By manually defining an SQL statement.

4. What is a Image Check Point in QTP?
Image Checkpoint checks the value of an image in your application or Web page. For example, you can check that a selected image's source file is correct.
Note: You create an image checkpoint by inserting a standard checkpoint on an image object.

5. What is a Page Check Point in QTP?
Page Checkpoint checks the characteristics of a Web page. For example, you can check how long a Web page takes to load or whether a Web page contains broken links.
Note: You create a page checkpoint by inserting a standard checkpoint on a page object.
Page checkpoints are supported for the Web add-in environment

6. What is a Standard Check Point in QTP?
Standard Checkpoint checks the property value of an object in your application or Web page. The standard checkpoint checks a variety of objects such as buttons, radio buttons, combo boxes, lists, and so forth. For example, you can check that a radio button is activated after it is selected or you can check the value of an edit box.

Standard checkpoints are supported for all add-in environments

7. What is a Table Check Point in QTP?
Table checkpoint checks information within a table. For example, suppose your application or Web site contains a table listing all available flights from New York to San Francisco. You can add a table checkpoint to check that the time of the first flight in the table is correct.

Note: You create a table checkpoint by inserting a standard checkpoint on a table object.

8. What is a Text Area Check Point in QTP?
Text Area Checkpoint checks that a text string is displayed within a defined area in a Windows application, according to specified criteria. For example, suppose your Visual Basic application has a button that says View Doc , where is replaced by the four digit code entered in a form elsewhere in the application. You can create a text area checkpoint to confirm that the number displayed on the button is the same as the number entered in the form.

Text area checkpoints are supported for Standard Windows, Visual Basic, and ActiveX add-in environments.

Text area checkpoints are also supported for some external add-in environments, such as Java.

9. What is the Diff between Image check-point and Bit map Check point?
Image Checkpoints checks the properties of the image and not the Actual image. So through image check points you can verify it index, ALT Tag, URL of the image.
While the Bitmap check points actually checks the image comparing bit by bit. Through this you can check the whole image or part of the image.

Virtual Object in QTP

Virtual Object in QTP

Our application may contain objects that behave like standard objects but are not recognized by QTP. We can define these objects as virtual objects and map them to standard classes, such as a button or a check box. QTP emulates the user's action on the virtual object during the run session. In the test results, the virtual object is displayed as though it is a standard class object.

For example, suppose you want to record a test on a Web page containing a bitmap that the user clicks. The bitmap contains several different hyperlink areas, and each area opens a different destination page. When you record a test, the Web site matches the coordinates of the click on the bitmap and opens the destination page.

To enable QTP to click at the required coordinates during a run session, you can define a virtual object for an area of the bitmap, which includes those coordinates, and map it to the button class. When you run a test, QTP clicks the bitmap in the area defined as a virtual object so that the Web site opens the correct destination page.

You define a virtual object using the Virtual Object Wizard (Tools > Virtual Objects > New Virtual Object). The wizard prompts you to select the standard object class to which you want to map the virtual object. You then mark the boundaries of the virtual object using a crosshairs pointer. Next, you select a test object as the parent of the virtual object. Finally, you specify a name and a collection for the virtual object. A virtual object collection is a group of virtual objects that is stored in the Virtual Object Manager under a descriptive name.

Note: QTP does not support virtual objects for analog or low-level recording.

Function Library in QTP

Function Library


We can create function libraries in QTP and call their functions from an action in our test. A function library is a separate QTP document containing VBscript functions, subroutines, modules, and so forth. Each function library opens in a separate window, enabling us to open and work on one or several function libraries at the same time. After you finish editing a function library, you can close it, leaving your QTP session open. You can also close all open function libraries simultaneously.

By implementing user-defined functions in function libraries and associating them with your test, you and other users can choose functions that perform complex operations, such as adding if/then statements and loops to test steps, or working with utility objects—without adding the code directly to the test. In addition, you save time and resources by implementing and using reusable functions.

QTP provides tools that enable you to edit and debug any function library, even if it was created using an external editor. For example, QTP can check the syntax of your functions, and the function library window provides the same editing features that are available in the Expert View.



Example:



Function val_from_excel(epath, esheet, erow, ecolumn)

Set exlApp = CreateObject("Excel.Application")
exlApp.WorkBooks.Open (epath)

Set my_sheet = exlApp.Sheets.Item(esheet)
value = my_sheet.Cells(erow, ecolumn)

exlApp.quit

Set exlApp = Nothing
msgbox value
'msgbox val_from_excel

End Function

call val_from_excel("C:\Test1.xls", "Sheet1", 3,3)

Various utilities and tools available in QTP

Various utilities and tools available in QTP

QTP Contains the following utilities and tools that assist you with the testing process:

Password Encoder: Opens the Password Encoder dialog box, which enables you to encode
passwords. You can use the resulting strings as method arguments or Data Table parameter values (tests only).

Remote Agent: Activates the QTP Remote Agent, which determines how QTP behaves when a test is run by a remote application such as Quality Center.

Silent Test Runner: (Relevant only for tests) Opens the Silent Test Runner dialog box, which enables you to run a QTP test the way it is run from LoadRunner and Business Availability Center.

Test Batch Runner: (Relevant only for tests) Opens the Test Batch Runner dialog box, which enables you to set up QTP to run several tests in succession.

Test Results Deletion Tool: Opens the Test Results Deletion Tool dialog box, which enables you to delete unwanted or obsolete results from your system according to specific criteria that you define.

Action Conversion Tool: Enables you to convert test actions that were created using QTP Professional to scripted components for use in business process testing. For more information, click the Help button in the Action Conversion Tool window.

License Validation Utility: Opens the License Validation utility, which enables you to retrieve and validate license information.

Register New Browser Control: Opens the Register Browser Control Utility, which enables you to register your browser control application so that QTP Professional recognizes your Web object when recording or running tests.

Business Component Upgrade Tool: Opens the Business Component Upgrade Tool, if you are connected to a Quality Center project. This tool enables you to upgrade all of the business components in a Quality Center project, from an earlier component version to the format required by the current version. For more information, click the Help button in the Business Component Upgrade Tool window.

QTP Script Editor: Opens the QTP Script Editor, which enables you to open and modify the scripts of multiple tests and function libraries, simultaneously.

Mercury Micro Player: Opens the Mercury Micro Player, which enables you to view captured movies of a run session without opening QTP.

What are the various ways of generating Statements in Expert View?

What are the various ways of generating Statements in Expert View?

a. Generating Statements in the Expert View or a Function Library
We can generate statements in the following ways:
  • We can use the Step Generator (Insert > Step Generator) to add steps that use methods and functions.
  • We can manually insert VBScript statements that use methods to perform operations. QTP includes IntelliSense, a statement completion feature that helps you select the test object (tests only), method, property, or collection (tests only) for your statement and to view the relevant syntax as you type in the Expert View or a function library.
  • When you start to type a VBScript keyword in the Expert View or a function library, QTP automatically adds the relevant syntax or blocks to your script, if the Auto-expand VBScript syntax option is enabled.

b. Generating a Statement for an Object
When you type in the Expert View or a function library, IntelliSense (the statement completion feature included with QTP) enables you to select the test object (tests only), method, property, or collection (tests only) for your statement from a drop-down list and view the relevant syntax.
The Statement Completion option is enabled by default. You can disable or enable this option in the Editor Options dialog box.

When the Statement Completion option is enabled:
• If you type an object followed by an open parenthesis (, for example, Page(, QTP displays a list of all test objects of this type in the object repository. If there is only one object of this type in the object repository, QTP automatically enters its name in quotes after the open parenthesis. (Tests only)
• If you type a period after a test object in a statement, QTP displays a list of the relevant test objects (tests only), methods, properties, collections (tests only), and registered functions that you can add after the object you typed.
• If you type the name of a method or property, QTP displays a list of available methods and properties. Pressing CTRL+SPACE automatically completes the word if there is only one option, or highlights the first method or property (alphabetically) that matches the text you typed.
• If you type the name of a method or property, QTP displays the syntax for it, including its mandatory and optional arguments. When you add a step that uses a method or property, you must define a value for each mandatory argument associated with the method or property.
• If you press CTRL+SPACE, QTP displays a list of the relevant test objects (tests only), methods, properties, collections (tests only), VBScript functions, user-defined functions, VBScript constants, and utility objects that you can add. This list is displayed even if you typed an object that has not yet been added to the object repository. If the test contains a function, or is associated with a function library, the functions are also displayed in the list.
• If you use the Object property in your statement, if the object data is currently available in the Active screen (tests only) or the open application, QTP displays native methods and properties of any run-time object in your application.

c. To generate a statement using statement completion in the Expert View or a function library:
1. Confirm that the Statement completion option is selected (Tools > View Options > General tab).
2. Perform one of the following:
o If you are working in a function library, skip to step 4.
o If you are working in the Expert View, type an object followed by an open parenthesis (.

If there is only one object of this type in the object repository, QTP automatically enters its name in quotes after the open parenthesis. If more than one object of this type exists in the object repository, QTP displays them in a list.

3. Double-click an object in the list or use the arrow keys to choose an object and press ENTER. QTP inserts the object into the statement.
4. Perform one of the following:
o If you are working in the Expert View, type a period (.) after the object on which you want to perform the method.

o If you are working in a function library, type the full hierarchy of an object, for example:

Browser("Welcome: Mercury Tours").Page("Book a Flight: Mercury).WebEdit("username").

5. Type a period (.) after the object description, for example ("username"). QTP displays a list of the available methods and properties for the object.
Tip: You can press CTRL+Space or choose Edit > Advanced > Complete Word after a period, or after you have begun to type a method or property name. QTP automatically completes the method or property name if only one method or property matches the text you typed. If more than one method or property matches the text, the first method or property (alphabetically) that matches the text you typed is highlighted.

6. Double-click a method or property in the list or use the arrow keys to choose a method or property and press ENTER. QTP inserts the method or property into the statement. If the method or property contains arguments, QTP displays the syntax of the method or property in a tooltip, as shown in this example from the Expert View.
In the above example, the Set method has one argument, called Text. The argument name represents the text to insert in the box.

Tip: You can also place the cursor on any method or function that contains arguments and press CTRL+SHIFT+SPACE or choose Edit > Advanced > Argument Info to display the statement completion (argument syntax) tooltip for that item.

7. Enter the method arguments after the method according to the displayed syntax.
Note: After you have added a step in the Expert View, you can view the new step in the Keyword View. If the statement that you added in the Expert View contains syntax errors, QTP displays the errors in the Information pane when you select the Keyword View.

Automatically Completing VBScript Syntax
When the Auto-expand VBScript syntax option is enabled and you start to type a VBScript keyword in the Expert View or a function library, QTP automatically recognizes the first two characters of the keyword and adds the relevant VBScript syntax or blocks to the script. For example, if you enter the letters if and then enter a space at the beginning of a line, QTP automatically enters:

If Then
End If

The Auto-expand VBScript syntax option is enabled by default. You can disable or enable this option in the Editor Options dialog box.

If you enter two characters that are the initial characters of multiple keywords, the Select a Keyword dialog box is displayed and you can select the keyword you want. For example, if you enter the letters pr and then enter a space, the Select a Keyword dialog box opens containing the keywords private and property.
You can then select a keyword from the list and click OK. QTP automatically enters the relevant VBScript syntax or block in the script.

QTP Interview Question Part 2

1. How can I remove test result files from old tests?
We can use the TEST RESULTS DELETION TOOL to view a list of all of the test results in a specific location in your file system or in your Quality Center project. You can then delete any test results that you no longer require.
The Test Results Deletion Tool enables you to sort the test results by name, date, size, and so forth, so that you can easily identify the results you want to delete.

To open this utility, choose Start > Programs > QTP Professional > Tools > Test Results Deletion Tool.

2. What are the ways by which we can make QTP to wait?

WaitProperty: We can insert a synchronization point, which instructs QTP to pause the test until an object property achieves the value we specify.
Syntax: Object.WaitProperty ("Property Name", Expected Value, Timeout)

Exist: Wait for specified time interval until an Object Existence become TRUE
Syntax: Object.Exist (Timeout)

Wait: Wait for specified time interval before continuing the test
Syntax: Object.Wait (Timeout)

3. How to handle dynamic objects in QTP?
QTP generally identifies an object by matching test object properties with run time object properties. It may fail to recognize the dynamic objects whose properties change during run time. QTP has an option of enabling Smart Identification wherein it can identify the objects even if their properties changes during run time.

Smart Identification mechanism uses two types of properties:
  • Base Filter Properties: This is most fundamental properties of a particular test object class whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from to any other value; you could no longer call it the same object.

  • Optional Filter Properties: Other properties that can help to identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable

4. Checkpoints in QTP
Type
Description
Mode of Applying
Example
Standard Checkpoint
Check Property Value of an Object
Recording Time
In Editing Test
Check that radio button is selected
Image Checkpoint
Check the property Value of an Image
Recording Time
Check that Image source file is correct
Bitmap Checkpoint
Check an area of webpage or application after capturing as Bitmap
Recording Time
In Editing Test
Check that webpage is displayed as expected
Table Checkpoint
Check the information in a Table
Recording Time
Check that value in a table cell is correct
Database Checkpoint
Check the content of database access by application
Recording Time
Check that Value in database query is correct
Text/Text Area Checkpoint
Check that text string is displayed at appropriate place in webpage or window application
Recording Time
In Editing Test
Check that whether string is displayed at expected place
Page Checkpoint
Check the characteristic of Page
Recording Time
Check that how long a web page takes to load
Accessibility Checkpoint
Identify the area of website to check for section 508 compliancy
Recording Time

XML Checkpoint
Check the data content of XML document
Recording Time
Check specified XML file

5. What is a Text and Text Area Check Point in QTP?
Text Checkpoint enables us to check that a text string appears within a screen, window, or Web page, as per the specified criteria. It is supported for all environments.

Text Area Checkpoint enables us to check that a text string appears within a defined area of a Windows application, as per the specified criteria. It is supported for Standard Windows, Visual Basic, and ActiveX environments.

6. What is Test Object Method in QTP?
The test object model is a large set of object types or classes that QTP uses to represent the objects in our application. Each test object class has a list of properties that can uniquely identify objects of that class and a set of relevant methods that QTP can record for it.
A run-time object is the actual object in our application on which methods are performed during the run session.
When you perform an operation on your application while recording, QTP:
  • Identifies the QTP test object class that represents the object on which we performed the operation and creates the appropriate test object
  • Reads the current value of the object's properties in our application and stores the list of properties and values with the test object
  • Chooses a unique name for the object, generally using the value of one of its prominent properties
  • Records the operation that we performed on the object using the appropriate QTP test object method

For example, suppose we click on a Search button with the following HTML source code:
<input name="Search" value="Search" type="submit">
QTP identifies the object that you clicked as a WebButton test object. It creates a WebButton object with the name Search, and records the following properties and values for the Search WebButton

7. Explain in brief about the QTP Automation Object Model.
Essentially all configuration and run functionality provided via the QTP interface is in some way represented in the QTP automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QTP have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods. You can use the objects, methods, and properties exposed by the QTP automation object model, along with standard programming elements such as loops and conditional statements to design your program.

8. What is a Run-Time Data Table? Where can I find and view this table?
In QTP there is a data table used which is used at runtime. This is basically an excel file which stored in the folder of test created. Its name is Default.xls by default.

Navigation: View->Data table

9. How does Parameterization and Data-Driving relate to each other in QTP?
For Data-Driving we have to make constant as parameter so that in each iteration, it takes the value from run time data table.

10. Explain the concept of how QTP identifies object.
During recording QTP looks at the object and stores it as test object. For each test object QTP learns a set of default properties called mandatory properties. It looks at the other objects property if the mandatory properties are not sufficient to create unique object property. During test run, QTP searches for the run time objects that match with the test object it learned while recording.