Forum Discussion

Usha_Kodali's avatar
Usha_Kodali
Frequent Contributor
14 years ago

how to access testRunner from the TearDown of TestSuite?

Hi,

I want to have the test step results printed for each test case by writing groovy script in the TearDown script of TestSuite.
Can you let me know how to access testRunner.results from the teardown script of TestSuite?

I tried following script but it complaints saying testRunner not found
import com.eviware.soapui.impl.support.http.HttpRequestTestStep
def testsuitename = testSuite.name
log.info(testsuitename)

for(testCase in testSuite.testCaseList)
{
if(!testCase.isDisabled())
{
log.info(testCase.name)

def logfilepath = "C:/Automation/Soapui/Shows/Log/"
def d1 = new File("${logfilepath}/${testsuitename}")
d1.mkdir()
logFile = new File("${d1}/${testCase.name}.log")
if(logFile.exists())
{
logFile.delete();
}
def today= new Date()

bufferedWriter = new BufferedWriter(new FileWriter("${d1}/${testCase.name}.log"));
bufferedWriter.writeLine "Run time:"
bufferedWriter.writeLine today.toString()
bufferedWriter.writeLine "Test case: $testCase.name"
bufferedWriter.writeLine("Test result count: ${testSuite.getTestCaseAt(4).getTestStepAt(1).testRunner.results.size()}")
def int i = 1
testRunner.results.each { testResult ->
String testStepName = testResult.testStep.name
bufferedWriter.writeLine "Test step $i '$testStepName'"
bufferedWriter.writeLine "Test step $i result: status $testResult.status, size $testResult.messages, messages: $testResult.messages"
++i
}

bufferedWriter.flush();
bufferedWriter.close();
}
}

4 Replies

  • MistaWizard's avatar
    MistaWizard
    Occasional Contributor

    I would really like to know how to achieve this. I'm assuming its a type of import and when i try the below

     

    import com.eviware.soapui.model.testsuite
    log.info testRunner

     

    i get

     

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script14.groovy: 1: unable to resolve class com.eviware.soapui.model.testsuite @ line 1, column 1. import com.eviware.soapui.model.testsuite ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class com.eviware.soapui.model.testsuite @ line 1, column 1. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1145) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) at org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:632) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:523) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613) at groovy.lang.GroovyShell.parse(GroovyShell.java:625) at groovy.lang.GroovyShell.parse(GroovyShell.java:652) at groovy.lang.GroovyShell.parse(GroovyShell.java:643) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87) at com.eviware.soapui.impl.wsdl.WsdlTestSuite.runTearDownScript(WsdlTestSuite.java:495) at com.eviware.soapui.impl.wsdl.panels.testsuite.WsdlTestSuiteDesktopPanel$TearDownScriptGroovyEditorModel$1.actionPerformed(WsdlTestSuiteDesktopPanel.java:405) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 1 error

    • fredsvar's avatar
      fredsvar
      SmartBear Alumni (Retired)

      com.eviware.soapui.model.testsuite is a package name, import expects a class or a wildcard. 

       

      Try 

      "import com.eviware.soapui.model.testsuite.*" instead

       

      The next line will probably also fail but I am not sure what you want to do there so I have no suggestions on how to fix it.

       

       

      • MistaWizard's avatar
        MistaWizard
        Occasional Contributor

        Thank you. I tried and got back to my first problem "No such property: testRunner"

        lol, so i just changed it to

         

        log.info TestRunner and it's working. awesome. Now to see if i can use it :)