Adding a Verification to a Script with Code

Insert a verification to determine if the script result matches the expected result.

  1. Open the script in which you want to include a verification.
  2. Insert one of the following verification methods:
    • To compare the expected value with the actual value, type:
      Workbench.Verify(expected As Object, actual As Object)

      For example, Workbench.Verify("red", "red") passes. While Workbench.Verify("red", "green") fails with the message Actual: [green]; Expected: [red].

    • To compare the expected value with the actual value and add a comment, type:
      Workbench.Verify(expected As Object, actual As Object, comment As String)

      For example, Workbench.Verify("red", "green", "checking colors") fails with the message checking colors - Actual: [green]; Expected: [red].

    • To compare the expected value with the actual value, to add a comment, and to add a screenshot to the result file if the verification fails, type:
      Workbench.Verify(expected As Object, actual As Object, comment As String, verifyFlags As VerifyFlags)

      For example, Workbench.Verify("red", "green", "checking colors", verifyFlags.ScreenShotOnFailure) fails with the message checking colors - Actual: [green]; Expected: [red] and adds a screenshot to the result file.

    • To verify the value returned by the expected result, type:
      Workbench.Verify(condition As Boolean)

      For example, Workbench.Verify(True) passes. While Workbench.Verify(False) fails.

    • To verify the value returned by the expected result and add a comment, type:
      Workbench.Verify(condition As Boolean, comment As String)

      For example, Workbench.Verify(True, "Test Passed") passes. While Workbench.Verify(False, "Test Failed") fails.

    • To verify the value returned by the expected result, to add a comment, and to add a screenshot to the result file if the verification fails, type:
      Workbench.Verify(condition As Boolean, comment As String, verifyFlags As VerifyFlags)

      For example, Workbench.Verify(True, "Test Passed", verifyFlags.ScreenShotOnFailure) passes and adds no screenshot. While Workbench.Verify(False, "Test Failed", ScreenShotOnFailure) fails and adds a screenshot to the result file.

    • To compare the actual value with the expected value for IEnumerable objects, such as lists and arrays, type:
      Workbench.Verify(expectedEnumerable, actualEnumerable) 
      For example:
      Dim selectedItemsList = listBox.SelectedItems ' we assume that a list with the items "red" and "blue" is returned
      Dim expectedItemsList = New List(Of String)()
      expectedItemsList.Add("red")
      expectedItemsList.Add("blue")
      
      Workbench.Verify(selectedItemsList, expectedItemsList)  ' verification passes
      
      Dim expectedItemsArray = New String() { "red", "blue" }
      Workbench.Verify(selectedItemsList, expectedItemsArray) ' verification passes
      
      Note: Two IEnumerable objects are considered equal if both have the same number of elements, and the elements are equal and in the same order.
      Note: Mathematical operations with floating point numbers may lead to two numbers that are not completely identical because of their internal representation, although they should be equal from a user point of view. Therefore, floating point numbers (Double, Single) are considered equal if their difference is less than 0.00001. At times, this value may not be correct for the situation. In this case, compare the two values with the Verify(result As Boolean) instead.