Forum Discussion
Manoj
14 years agoContributor
Hi,
In other words , the adding assertions works if we add to different steps, but it behaves strange when we add assertions to the same step and run on loop.
The below code works for me , but I want to avoid to create the different steps in test suite and adding separate assertion.
Please let me know if this is possible...
for(i in 1..30 )
{
def subscriberListValue =holder["//Row[$i]/SUBSCRIBER_ID[1]"]
def props1 = testRunner.testCase.getTestStepByName("$i" + "Count_GetDistinct_MembersforEach_SubscriberID" ) // This is my JDBC Step where I am adding the assertion //
def assertionsList = testRunner.getTestCase().getTestStepByName("$i" +"Count_GetDistinct_MembersforEach_SubscriberID").getAssertionList()
for( e in assertionsList){
testRunner.getTestCase().getTestStepByName("$i" +"Count_GetDistinct_MembersforEach_SubscriberID").removeAssertion(e)
}
def assertionName = "AssertXPATH" + "$i"
def assertText = testRunner.getTestCase().getTestStepByName("Properties").getPropertyValue("assert_Text") // This is "count(//MEMBER_ID)"
def assertion = testRunner.getTestCase().getTestStepByName("Count_GetDistinct_MembersforEach_SubscriberID").addAssertion("XPath Match")
println " \n\n ########## Assertion Name " + assertionName
assertion.name = assertionName
assertion.path = assertText
assertion.expectedContent = noOfMember // This is the number of members from a XML file and it changes according to my XPATH each time
testRunner.runTestStepByName("$i" +"Count_GetDistinct_MembersforEach_SubscriberID")
}
In other words , the adding assertions works if we add to different steps, but it behaves strange when we add assertions to the same step and run on loop.
The below code works for me , but I want to avoid to create the different steps in test suite and adding separate assertion.
Please let me know if this is possible...
for(i in 1..30 )
{
def subscriberListValue =holder["//Row[$i]/SUBSCRIBER_ID[1]"]
def props1 = testRunner.testCase.getTestStepByName("$i" + "Count_GetDistinct_MembersforEach_SubscriberID" ) // This is my JDBC Step where I am adding the assertion //
def assertionsList = testRunner.getTestCase().getTestStepByName("$i" +"Count_GetDistinct_MembersforEach_SubscriberID").getAssertionList()
for( e in assertionsList){
testRunner.getTestCase().getTestStepByName("$i" +"Count_GetDistinct_MembersforEach_SubscriberID").removeAssertion(e)
}
def assertionName = "AssertXPATH" + "$i"
def assertText = testRunner.getTestCase().getTestStepByName("Properties").getPropertyValue("assert_Text") // This is "count(//MEMBER_ID)"
def assertion = testRunner.getTestCase().getTestStepByName("Count_GetDistinct_MembersforEach_SubscriberID").addAssertion("XPath Match")
println " \n\n ########## Assertion Name " + assertionName
assertion.name = assertionName
assertion.path = assertText
assertion.expectedContent = noOfMember // This is the number of members from a XML file and it changes according to my XPATH each time
testRunner.runTestStepByName("$i" +"Count_GetDistinct_MembersforEach_SubscriberID")
}