Forum Discussion

Prudential_UK_A's avatar
Prudential_UK_A
Frequent Contributor
15 years ago

Custom Assertion

Hi,
Currently I am using script assertions to assert response values that depends on relationships(greater than, less than, equals) between request field values, also response values that depends on existence of elements in the request etc.
Is it possible for me to write custom assertions that non-technical users can use? I want to have it set up so that they can configure it with xpath values for the request values to compare, xpath for response value to assert and acceptable response values for true and false cases?
Regards
Peter

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,
    You could define properties in a Properties TestStep, that could be easily modified by non-technical users, and then use property expansion in XPath Match assertion. For example, if using our Sample Project from Tutorial distributed with soapUI installation, where #Item,# least and #most are predefined properties

    declare namespace sam='http://www.soapui.org/sample/';
    //sam:searchResponse/item[id="${Properties: Wanted Response#Item}"]/price >= ("${Properties: Wanted Response#least}")
    and
    //sam:searchResponse/item[id="${Properties: Wanted Response#Item}"]/price <= ("${Properties: Wanted Response#most}" )

    can be used for comparing if search response value is in some predefined range.
    I hope this was what you meant.

    Regards,
    /Dragica
    eviware.com
  • Prudential_UK_A's avatar
    Prudential_UK_A
    Frequent Contributor
    that would be a good solution except I have about 16 assertions so that will need 16 properties and the assertions iwll have references to the properties hard coded.
    Can I not implement ResponseAssertion and RequestAssertion and define gui for configuration and add the assertion to soapui?