Forum Discussion

coexmatrix's avatar
coexmatrix
Occasional Contributor
15 years ago

Harvesting a Value for a specific test step

Hello,
I have a test case that contains several test steps.

I am using a groovy script to successfully pull the timeTaken value for all test steps within the testCase using the following line
def timeTaken = String.valueOf( testRunner.results.timeTaken )

I am then recording this value in a MySQL database.

However, I need to only record the timeTaken value for one individual teststep, I do not need the timeTaken values for any of the other test steps.

Further compounding the issue is the fact that the Groovy Script I am using to gather and write this value to the DB must be executed at the end of the Test Case, and the individual TestStep I need to gather the timeTaken value from must be at the beginign of the TestCase.

Any help is greatly appreciated to harvest a specific teststep timeTaken value.

Heres the full script I'm using:
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.model.testsuite.TestRunContext;
import com.eviware.soapui.model.testsuite.TestRunner;
import com.eviware.soapui.model.testsuite.TestRunner.Status
import com.eviware.soapui.model.testsuite.TestStepResult;
import groovy.sql.Sql

def Service = context.expand( '${#Project#Service}' )
def API = context.expand( '${#TestSuite#API}' )
def TestSuite = context.expand( '${#TestSuite#TestSuite}' )
def TestCase = context.expand( '${#TestCase#TestCase}' )
def TestTime = context.expand( '${TestTime#result}' )
def timeTaken = String.valueOf( testRunner.results.timeTaken )
def timeTaken = context.expand( '${Advanced timeTaken#result}' )
def status = context.expand( '${status#status}' )

sql = Sql.newInstance("jdbc:mysql://localhost:3306/test", "username", "pass", "com.mysql.jdbc.Driver")
sql.execute("insert into BHealth (Service, API, TestSuite, TestCase, TestTime, timeTaken, Status) values ('${Service}', '${API}', '${TestSuite}', '${TestCase}', '${TestTime}', '${timeTaken}', '${status}')")
true
No RepliesBe the first to reply