How to use the conditional assertion namely IF... ELSE in SOAtest?

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
Dear Sir,

In output XML, choose SOAP envelop -> XML Assertor. Now, for this, select compound Assertions. It has AND. OR & Conditional assertions. Choose conditional assertion. Then, add String & Numeric assertions. Then, group them under Conditional assertion. Now, Conditional assertion has IF and THEN. But, i need to have IF and ELSE assertion
in addition to IF and THEN. How to configure the same?

For ex:

Refer the PseudoCode:

IF (RESULT = FAILURE)
THEN (ERROR CODE = 100)
ELSE
IF (RESULT = SUCCESS) AND (COUNTRY = INDIA)
THEN
CITIZEN = INDIAN
ELSE
CITIZEN = NON INDIAN

For this example, please configure the Output assertion and if possible send us the .tst file for my reference.

Thanks in advance.

Regards,
Sreesha
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    edited September 2008
    Hi,
    I suggest using an alternative way to test your functionality. Try to separate for more steps your functionality.
    I believe it is important, because SOAtest is not able to use 'ELSE'. So far I have only found IF...THEN ( at Conditional assertor tool).


    TestSuite folder
    1. Test1:
    Call your test simly wich will cause failure in result. And use ValueAssertor tool for checking failure.
    It will done it: (IF (RESULT = FAILURE) THEN (ERROR CODE = 100)
    2. Test2: Also call the same test with correct input and country=India parameter. Check the Citizen=Indian in result by ValueAssertor tool.
    It will done it: IF (RESULT = SUCCESS) AND (COUNTRY = INDIA)
    THEN
    CITIZEN = INDIAN
    3. Test3: Finally call your the same test where Country parameter does not have INDIA value and check the Citizen in response by simple ValueAssertor.


    If you have done above Scenario, you just need to set the 'Test Flow Logic' at the Scenario folder. It can be found under 'Execution Options' menu after selecting Scenario folder.
    Here go to the Test2 and set Test Result Dependency to Test1 and select Failure radiobutton. It means that if Test1 has Errorcode=100, then Your scenario will be broken and SOAtest will not run Test2.
    At the Test3, you also need to set 'Test Result Dependency' to Test2 and select Failure radiobutton.

    Finally check the 'Execution Mode'. It must be set to 'Test run sequantially'.

    Regards,
    Kevin
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    edited September 2008
    Hello Kevin, Sreesha,

    The option suggested by Kevin should work, but may not be the optimal or cleanest solution to your problem, Sreesha. Instead of creating three tests, two of which may not run due to Test Flow Logic, you can create an assertion like the tree below:

    OR
    |
    + - IF (RESULT = FAILURE)
    | + THEN (ERROR CODE = 100)
    |
    + - IF (RESULT = SUCCESS) AND (COUNTRY = INDIA)
    | + THEN CITIZEN = INDIAN
    |
    + - IF (RESULT = SUCCESS)
    | + THEN CITIZEN = NON INDIAN

    This way, if any of the three conditions are true, your assertion passes. This also removes the need for multiple SOAP clients and the need for Test Flow Logic.

    Regards,
    Joseph
Sign In or Register to comment.