Forum Discussion

skyhigh's avatar
skyhigh
Contributor
7 years ago
Solved

Is it possible to call assert with my own test result (Pass or Fail)?

Hi,

 

I would like to know if it's possible if I validate the test results with my own logics then call the assertion script to either pass/true or fail/false based on my own reasoning?  thanks

  • Are you trying to validate each testcase with 'Script Assertion (groovy script)'?

    If so, then you can pass or fail that script by using 'assert' then pass a true or false (boolean) condition on it, true (passed), false (failed)

     

    e.g.
    def getTotalNumbers = totalNumbersFromResponse;
    def expectedTotal = 10;
    
    assert getTotalNumbers == expectedTotal; // if both matches, your testcase will pass, else fail

     

4 Replies

  • Are you trying to validate each testcase with 'Script Assertion (groovy script)'?

    If so, then you can pass or fail that script by using 'assert' then pass a true or false (boolean) condition on it, true (passed), false (failed)

     

    e.g.
    def getTotalNumbers = totalNumbersFromResponse;
    def expectedTotal = 10;
    
    assert getTotalNumbers == expectedTotal; // if both matches, your testcase will pass, else fail

     

    • skyhigh's avatar
      skyhigh
      Contributor

      thanks.  I didn't know why I didn't do this "assert true"

  • nmrao's avatar
    nmrao
    Champion Level 3
    What are you trying to do? If you already applied your logic to validate the result, why do want to call assertion script?
    • skyhigh's avatar
      skyhigh
      Contributor

      The reason I want to validate my own test result because I test one of the features that member requires license to perform the operation.  Since the license team hasn't fixed their defects and I cant fail that tested feature because the developer who owns that feature says it's not the functionality fault, it's the requirement does not meet so he wants me to pass the test case rather fail or block it.  Sometimes developers just have their own reasoning when deciding whether to pass or fail the test.