Forum Discussion

kharbpunit's avatar
kharbpunit
New Contributor
11 years ago

How to add assertion on test step of another testcase

Hi,

I have created multiple test cases in a suite.
In first testcase I have placed my rest request. So in another testcase I have to assert response of that rest request.
Please suggest, how can I add assertion from second test case on first testcase.

Thanks
Punit
  • SiKing's avatar
    SiKing
    Community Expert
    This does not really make sense. Could you describe the problem you are trying to solve, and not the solution you are trying to achieve.

    What you describe is possible, but I am not sure why, so it would be difficult for me to explain.
  • kharbpunit's avatar
    kharbpunit
    New Contributor
    I want to replicate my excel testcases into soapui. So I created a testcase which hit webservice and in other testcases I automated my all testcases. I solved my earlier problem by making webservice response as Global which is now accessible to every testcase.

    If you have any better approach or any suggestion then please suggest
  • Cizo89's avatar
    Cizo89
    Frequent Contributor
    Hi,

    I'm also little bit confused here.
    Why not assert the response of that service in the first TestCase? Why you need to call the service in TestCase 1 and then add assertions from TestCase 2?

    But if you really want to do this, here is an example of how to clone assertions from one TestStep to another:

    for (assertion in testRunner.testCase.testSuite.testCases["TestCase 2"].testSteps["Request 2"].getAssertionList()){
    testRunner.testCase.testSuite.testCases["TestCase 1"].testSteps["Request 1"].cloneAssertion(assertion, assertion.getName())
    }


    Regards,
    Marek