Service Virtualization

  • 1.  Assertions to alter the flow of test

    Posted Aug 23, 2017 10:40 AM

    # monika mehta 

    Devtest 8.2 - automation 

     

    There are two questions here 

    First question 

    1. Would want to know the difference between abort the test and fail the test for assertions . If an assertion is true , gave the flow to be aborted , but its still continuing to the next step.

     

    Second question 

    2. I want to stop the execution flow if current execution status is 400 or 500 series status code . Below scripted assertion is not working . Ps let me know the correct assertion to abort the test 

     

    if(testExec.getStateValue("lisa.getWarrantyeligibility.http.responseCode").equals("4/d/d") || (testExec.getStateValue("lisa.getWarrantyeligibility.http.responseCode").equals("5/d/d")))
    return true;

     

    Its returning false and ts going to next step. 



  • 2.  Re: Assertions to alter the flow of test

    Posted Aug 24, 2017 06:18 AM

    Hi Rajeswari,

     

    1- There is a type mismatch inyour script:

    if(testExec.getStateValue("lisa.getWarrantyeligibility.http.responseCode").equals("4/d/d") || (testExec.getStateValue("lisa.getWarrantyeligibility.http.responseCode").equals("5/d/d")))

     

    (testExec.getStateValue("lisa.getWarrantyeligibility.http.responseCode") is returning the Integer value, but you comparing as String

    Solution: Compare them as integer value only.

     

    2- You comparing with "4/d/d" which is a regular expression, response code is 200,400,500 etc are pure integer value, these can not be compared against Regular expression directly.

    Solution:

    Apply a Java method that compare characters against the regular expression.

    Or,

    Give constant values like 400,500 etc as expected.

     

    e.x:

    if(testExec.getStateValue("lisa.getWarrantyeligibility.http.responseCode") == 400 || (testExec.getStateValue("lisa.getWarrantyeligibility.http.responseCode") == 500)))

     

    Check if it helps.

     

    Thanks,

    Dinesh Kumar



  • 3.  Re: Assertions to alter the flow of test

    Posted Aug 29, 2017 10:07 AM

    status code can be 400, 401 , 404 ,501 , 503 . can you please help with a sample code to abort the test for the mentioned status code



  • 4.  Re: Assertions to alter the flow of test
    Best Answer

    Posted Aug 24, 2017 09:00 PM

    Hi Rajeshwari,

     

    As suggested by Dinesh, please update your scripted assertion to compare integer values not string.

    For the first question, Abort vs fail Test case.

    - The Abort the Test step quits the test case and marks the step as having aborted.

    - The Fail the Test step fails the test case and marks the test as having failed.

    It is possible that assertion is returning true. Please check test events in case it is returning true and stll not aborting, we will look into it.

     

    Debugging tips: There is always failure reason in test events. 

    You can paste the same code in java step and see if it is throwing any error. 

     

    Standard Options in Test Steps - DevTest Solutions - 10.0 - CA Technologies Documentation 

     

    Thanks,

    Monika