Want to mark test step as failed
HI all
I want to set teststep as fail when i run it from test suite (below is my scenario)
I created Two test suites
1. one is parent one
2. Child one which has all reusable classes and this suite is in disabled state
In Parent one i am running two of my child Groovy script classes , my problem is if i get any error in first step my second step stops running this is because i am using "assert", so for alternative to assert i used testRunner.fail("") i n this case my both groovy test steps are running successfully but test step is not marked in red, i want this step to be marked as red
Parent groovy i written below script
import com.eviware.soapui.support.XmlHolder
import groovy.util.XmlSlurper
def tcase = testRunner.testCase
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def currentStepInd = context.currentStepIndex
def previousStep = testRunner.testCase.getTestStepAt(currentStepInd - 2)
def WDTestStepName = previousStep.name
def request1 = groovyUtils.getXmlHolder("NewBusiness#Request")
def response = groovyUtils.getXmlHolder("NewBusiness#Response")
def responseHolder1 = groovyUtils.getXmlHolder(WDTestStepName+"#Response")
responseHolder1.namespaces["ns1"]= "http://www.ssp-uk.com/Mqh/WorkingData"
def WDresponse = context.expand( '${'+WDTestStepName+'#Response#//*:WorkingData}' )
//log.info "WDresponse-->"+WDresponse
tcase.getTestSuite().removeProperty("WDResponse")
testRunner.testCase.testSuite.setPropertyValue("WDResponse",WDresponse)
verify_check_response = testRunner.testCase.testSuite.project.testSuites["ReusableClassScript"].testCases["ReUsableClassTC"].testSteps["verify_check_response"]
verify_check_response.run(testRunner, context)
def verifyCheckResponse = context.vcRes.verify_check_response(TSuiteName)
verify_check_response_Prior = testRunner.testCase.testSuite.project.testSuites["ReusableClassScript"].testCases["ReUsableClassTC"].testSteps["verify_check_response_Prior"]
verify_check_response_Prior.run(testRunner, context)
context.vcResP.verify_check_response_Prior(TSuiteName,transactionType)
in my Child steps in 2nd test suite
class ClassScript
{
def log
def context
def testRunner
def ClassScript(logIn, contextIn, testRunnerIn)
{
this.log = logIn
this.context = contextIn
this.testRunner = testRunnerIn
}
//Till abobe line you must keep same code except class name
public verify_check_response(String TSuiteName)
{
log.info "..............verify_check_response Script Execution..................."
def utils = new com.eviware.soapui.support.GroovyUtils( context )
def tcase = testRunner.testCase
def responseHolder1 = utils.getXmlHolder(testRunner.testCase.testSuite.project.testSuites[TSuiteName].getPropertyValue("WDResponse"))
def error = []
def verifyCheckResponse
--------------------------------------------------
--------------------------------------------------
if(error.size() > 0)
{
verifyCheckResponse = " $error "
if(error.size() == 0){ verifyCheckResponse = "Success"
log.info "Script Passed" }
return verifyCheckResponse
}
}
context.setProperty("vcRes", new ClassScript(log, context, testRunner))
IN another child test step also i written code same like above with different conditions
SO what i want to do in Parent groovy script is just simply
if(verifyCheckResponse != "Success" )
{
Here i want to fail the child groovy class test step 1 from test suite 2 --> is this is possible (i tried everything by searching in google but i didnt find any solution for this) (for clear picture my folder structure find attached Image)
}
your answer would be really appreciated
thanks
Anusha