Forum Discussion

sampath's avatar
sampath
New Contributor
13 years ago

Clone Assertions to all test cases

Is there any way to clone the assertions to all test cases in the test suite, like how we clone to all test steps in a test case? Also can we view the assertions list added to all test cases in the test suite

2 Replies

  • nehavins's avatar
    nehavins
    Occasional Contributor
    Right Click on the Test Step from which you want to clone assertions. You can find an option to do so. Now select the target test case to which you want to add assertions.
  • Aaronliu's avatar
    Aaronliu
    Frequent Contributor
    Hi sampath,

    maybe you can refer to
    import com.eviware.soapui.model.testsuite.Assertable 
    def project = context.testCase.testSuite.project
    def testSuite = project.getTestSuiteAt(1)
    def testCase = testSuite.getTestCaseAt(0)
    def sourceTestStep = context.expand( ‘${#TestCase#SourceTestStep}’ )
    def targetTestStep = context.expand( ‘${#TestCase#TargetTestStep}’ )

    def testStepsrc=testCase.getTestStepByName(sourceTestStep)
    def testStepTrgt = testCase.getTestStepByName(targetTestStep)
    def counter = testStepSrc.getAssertionList().size()
    for (count in 0..<counter)
    {
    testStepTrgt.cloneAssertion(testStepSrc.getAssertionAt(count), testStepSrc.getAssertionAt(count).getName())
    }



    Regards,
    Aaron