Assertions

Purpose

An assert statement is a special Boolean condition that represents an assumption about program state at a particular point in test execution.  When an assert is encountered, the condition is evaluated.  A value of False indicates a program error.  In some languages, execution will halt if an assertion evaluates to False.  In Rapise, the result is logged to the report with failed status, and execution continues or not depending on StopOnError test option.

Create a Checkpoint

To create a checkpoint using an assertion, you will have to manually alter the test script (another way is to use the Verify Object Properties dialog during Recording):

  1. Select a location in your script.
  2. Query for the application state. For object properties use Get<..> methods.  For example:

    var xx = SeS("OkButton").GetX(); // X position of the object
    var image = SeS('Customer').GetBitmap(); // Image of the object
    
  3. Save the state (optional).  If you are creating an image checkpoint, you may want to save the image to a file.  If you are looking at text data, you could use a database, spreadsheet or text file.  The Spreadsheet object gives you access to Excel spreadsheets.

  4. Compare. Use the ImageWrapper class to compare images; use Spreadsheet to read and compare spreadsheet data.
  5. Write an Assert Statement. Make an appropriate call to one of Tester.Assert methods. Besides a Boolean condition, pass additional data to be placed in the Report. Read about Tester.Assert syntax in the Libraries documentation part.

Example: Simple Property Checkpoint

JavaScript

Tester.AssertEqual("Verify that: ColumnCount=11", SeS('DataGridView').GetColumnCount(), 11);

RVL

property rvl

Failure Representation in Report

property fail

Example: Bitmap Checkpoint

JavaScript

Tester.AssertImage("Compare Customer bitmap to Images\\Checkpoint0001.png",
    SeS('Customer').GetBitmap(), Global.GetFullPath("Images\\Checkpoint0001.png"));

RVL

bitmap rvl

Failure Representation in Report

bitmap fail

See Also