Forum Discussion

krogold's avatar
krogold
Regular Contributor
7 years ago

How to implement logic at testsuite level ?

Hello,

 

Is there any way to implement logic at testSuite level ?

What I'm trying to achieve is to implement setup or teardown scripts feature that would apply on every testCase of my testSuite.

Of course, these scripts would include variables that would take values according to the current running test case ...

 

If anyone knows ...

So far I tried to do this in setup script and it failed with a

groovy.lang.MissingPropertyException: No such property: testRunner for class: Script1

message. 

Maybe SOAP ui could be configured ?

 

 

  • After further investigation, I managed to do a complete summary of my tests, test cases and test steps, in my testSuite teardown script:

    def runner = context.testRunner;
    
    for (testRun in runner.getResults())
    {
    	testCase = testRun.getTestCase()
    	//log.info "testCase " + testCase
    	log.info context.expand( '${#Project#testcase_flag}' ) + testCase.getName()
    
    	for (testResult in  testRun.getResults())
    		log.info testResult.getTestStep().getName() + " : " + testResult.getStatus()
    	
    	log.info context.expand( '${#Project#testcase_status_flag}' ) + " : " + runner.getStatus()
    }
  • krogold's avatar
    krogold
    Regular Contributor

    So far, it is possible to implement something in the teardown script :

    ie, I want a summary of execution for my testCases :

    for (testCase in context.testRunner.getResults())
    {
    	log.info  testCase.getTestCase().getName() + " : " + testCase.getStatus()
    }

    this provides me with information <testcase> : <status>

     

    If someone has other methods or manages to do things in setupscript, don't hesitate to post !  :)

    • krogold's avatar
      krogold
      Regular Contributor

      After further investigation, I managed to do a complete summary of my tests, test cases and test steps, in my testSuite teardown script:

      def runner = context.testRunner;
      
      for (testRun in runner.getResults())
      {
      	testCase = testRun.getTestCase()
      	//log.info "testCase " + testCase
      	log.info context.expand( '${#Project#testcase_flag}' ) + testCase.getName()
      
      	for (testResult in  testRun.getResults())
      		log.info testResult.getTestStep().getName() + " : " + testResult.getStatus()
      	
      	log.info context.expand( '${#Project#testcase_status_flag}' ) + " : " + runner.getStatus()
      }