Forum Discussion

TesterNo1's avatar
TesterNo1
Contributor
9 years ago
Solved

Event -"TestRunListener.beforeRun" triggered multiple times.

Event -"TestRunListener.beforeRun" triggered multiple times.

 

I am trying to run a test case from another test suite in TestRunListener.beforeRun event  and i see the event is trigerred n --multiple times.I just printed a  string in the callee test case and i see the event never stops.Am i missing something ?

  def GetTC=testRunner.testCase.testSuite.project.getTestSuiteByName("mysuite").getTestCaseByName("mytc")
  def properties = new com.eviware.soapui.support.types.StringToObjectMap()
  def async = false
  GetTC.run(properties,async)

 

  •  

    i figured out the solution to this issue.Handle of callee test case is not resetign in the event once set.

    So,i am now sending the details of caller test case and test suite to callee test case.Callee test case will directly set the values into properties of caller test case.

5 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Do you consider to run the test case as a step ' Run Test Case'?
    • TesterNo1's avatar
      TesterNo1
      Contributor

      yes.That should be fine.But i dont have  a clue on how to try running using tetstrunner.run in this case where test case is located outside the test suite ?

       

      After testrunner.run ,i might have to forcefully come out of the runtestby otherwise it will repeat multiple times.Is there anyway to pass the runner like testRunner.fail () or cancel ?

       

      testRunner.runTestStepByName("MySQLWrite")
      //testRunner.cancel()
      testRunner.fail()

      • TesterNo1's avatar
        TesterNo1
        Contributor

        update on this issue.I dont see the test case running multiple times anymore.Now, i see handle is not getting returned to caller test case from callee test case.i have underlined the lines that causing issue where i try to set property in caller test case.Doesnt seem to work.Any guesses ?

         

        CurTsLbl=testRunner.testCase.getTestSuite().getLabel().toString()
        CurTcLbl=testRunner.testCase.getLabel().toString()
        CurTCHandle=testRunner.testCase.testSuite.project.getTestSuiteByName(CurTsLbl).getTestCaseByName(CurTcLbl)
        MtnTCHandle=testRunner.testCase.testSuite.project.getTestSuiteByName("GetMtnFromVision").getTestCaseByName("GetMtn")
        
        	//Check Mtn Criteria
        	strMtnCriteria=testRunner.testCase.getTestStepByName("Properties").getPropertyValue("MtnCriteria")
        	strDeviceType=testRunner.testCase.getTestStepByName("Properties").getPropertyValue("deviceType")
        	if (strMtnCriteria.length()>0)
        	{
        		strVisionEnv=testRunner.testCase.testSuite.getPropertyValue("VisionEnv")
        		log.info strVisionEnv
         		def properties = new com.eviware.soapui.support.types.StringToObjectMap()
          	     def async = false
          	     MtnTCHandle.getTestStepByName("Properties").setPropertyValue("MtnCriteria",strMtnCriteria)
          	     MtnTCHandle.getTestStepByName("Properties").setPropertyValue("VisionEnv",strVisionEnv)
                  MtnTCHandle.run(null,async)
                  def returnedStr= MtnTCHandle.getTestStepByName("Properties").getPropertyValue("returnStr")
                  if (returnedStr.length()>0)
                  {
                  tempArray=returnedStr.split("#")//contains mdn[0],ssn[1],deviceid[3]
                  CurTCHandle=testRunner.testCase.testSuite.project.getTestSuiteByName(CurTsLbl).getTestCaseByName(CurTcLbl)
                  log.info CurTsLbl
                  log.info "%%%%%"
                  log.info CurTcLbl
                  CurTCHandle.getTestStepByName("Properties").setPropertyValue("mobileNumber",tempArray[0])
                  CurTCHandle.getTestStepByName("Properties").setPropertyValue("ssn",tempArray[1])
                  }
                  else
                  {
                  	testRunner.fail("no mdn found for criteria")
                  	testRunner.testCase.getTestStepByName("TestRunnerProperties").setPropertyValue("TestLastFailedStep","no mdn found for criteria")
                  }
                  
               }
        
               
               
        
        
        
        

         

    • TesterNo1's avatar
      TesterNo1
      Contributor

      Rao,

      i couldnt figure out how to run the test case from other test suites from event handler.Also context handle is not changing meaning i am not able to change control to another test suite. Any idea why ?

       

      thank you.

      • TesterNo1's avatar
        TesterNo1
        Contributor

         

        i figured out the solution to this issue.Handle of callee test case is not resetign in the event once set.

        So,i am now sending the details of caller test case and test suite to callee test case.Callee test case will directly set the values into properties of caller test case.