If we need to add some basic assertions at runtime using Groovy, then following can be useful for you
Similarly you can add more assertion based on your requirements. Now for the different properties that you need to set, you can refer the API doc provided by the SOAPUI http://www.soapui.org/apidocs/index.html
def project = testRunner.testCase.testSuite.project
def testst = project.getTestSuiteAt(0).getTestCaseAt(0).getTestStepAt(0)
Adding CONTAINS assertiondef testst = project.getTestSuiteAt(0).getTestCaseAt(0).getTestStepAt(0)
def assertioncontains = testst.addAssertion("Contains")
assertioncontains.name = "contains assert"
assertioncontains.setToken("54")
assertioncontains.setIgnoreCase(true)
assertioncontains.setUseRegEx(true)
Adding NOT Contains assertionassertioncontains.name = "contains assert"
assertioncontains.setToken("54")
assertioncontains.setIgnoreCase(true)
assertioncontains.setUseRegEx(true)
def assertionnotcontains = testst.addAssertion("Not Contains")
assertionnotcontains.setToken("50")
assertionnotcontains.setIgnoreCase(true)
Adding XPATH Match assertionassertionnotcontains.setToken("50")
assertionnotcontains.setIgnoreCase(true)
def assertionxpath = testst.addAssertion("XPath Match")
assertionxpath.name = "xpath assert"
assertionxpath.setPath("path")
assertionxpath.setExpectedContent("expected content")
assertionxpath.setAllowWildcards(true)
Adding XQuery Match assertionassertionxpath.name = "xpath assert"
assertionxpath.setPath("path")
assertionxpath.setExpectedContent("expected content")
assertionxpath.setAllowWildcards(true)
def assertionxquery = testst.addAssertion("XQuery Match")
assertionxquery.setPath("path")
assertionxquery.setExpectedContent("expected content")
assertionxquery.setAllowWildcards(true)
assertionxquery.setPath("path")
assertionxquery.setExpectedContent("expected content")
assertionxquery.setAllowWildcards(true)
how to add Valid http status code assertion
ReplyDeleteUltimate ..Thanks
ReplyDelete