cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the milliseconds between 2 TestSteps

SOLVED
Highlighted
New Contributor

Getting the milliseconds between 2 TestSteps

I am trying to check the performance of a deploy API.

 

I am using these steps to get the time it takes to deploy. 

 

-Start Time ([Groovy Script] This sets a custom property with the current time in this format "HH:mm:ss.SSS")

-Deploy ([API] This only start the job, we need another step to make sure the job is done and done right)

-Transfer jobID (Standard property transfer)

-Query Job Status ([API] This gets the status of a job from the jobID)

-Check Job Status ([Groovy Script] a script that goto "Query Job Status" if job is not complete)

-End Time (This sets a custom property with the current time in this format "HH:mm:ss.SSS" and adds 1 to a counter)

-Loop condition (If counter is not equal to predetermined amount, goto TestStep "StartTime")

 

How do I calculate the milliseconds between the 2 custom properties "StartTime" and "EndTime"?

Or

How do I get the time between 2 TestSteps?

Whichever makes more sense to use.

 

This is how I create the time stamp in the custom properties:

 

String strCurrentDate = new Date().format("HH:mm:ss.SSS")
startTlime = strCurrentDate
testRunner.testCase.setPropertyValue("StartTime", startTime)

 

 

This is my last attempt at getting the difference between the 2 values

 

def startTime = testRunner.testCase.getPropertyValue( 'StartTime' )
def endTime = testRunner.testCase.getPropertyValue( 'EndTime' )
Date ParsedStartTime = Date.parse("HH:mm:ss.SSS", startTime)
Date ParsedEndTime = Date.parse("HH:mm:ss.SSS", endTime)
Date rateDuration = Date.(ParsedEndTime - ParsedStartTime)

 

 

I've tried many ways to manipulate the data like String, Date, .format(), .parse(), alone and combined. I am not able to make it work

Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
New Contributor

Re: Getting the milliseconds between 2 TestSteps

@HimanshuTayal 

That is the closest to what I've actually done.

 

for every loop I write the times in a custom property with an iteration in the property name (StartTime1, EndTime1)

The last step of the TC is a groovy script that logs all of the start and end time into a single text file which I import in Excel to parse and get results.

 

I was hoping for soapui to get the final answer for this test but after all that research and the suggestions here, I think that only excel can offer me the answer I seek.

 

Thanks to you two for the help.

View solution in original post

9 REPLIES 9
Highlighted
Community Hero

Re: Getting the milliseconds between 2 TestSteps

Even if there are no steps for getting start and end times, SoapUi collects or show time taken. Isn't it?

You can see below how much time spend for each and step and cumulative.

If you want the value, access it in TearDown script as shown below.

 

nmrao_1-1591702447315.png

 

 



Regards,
Rao.
Highlighted
Community Leader

Re: Getting the milliseconds between 2 TestSteps

@Klaael :

 

Hope you will get some help from below link.

 

calculate-difference-between-2-date-time-in-soapui 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
New Contributor

Re: Getting the milliseconds between 2 TestSteps

@nmrao 

This would not work. The API starts the job and I need to know how much time it took to complete without the time of the other steps.

I also need to run that at least 10 times to test the performance.

Community Leader

Re: Getting the milliseconds between 2 TestSteps

@Klaael :

 

i would suggest that you would use any performance testing tool, if you want to do this via SoapUI, then you implement following structure:

 

1. add Groovy Script before your Test Step

2. write the start time into Properties Step with iteration number(as you want to run multiple times)

3. add script assertion in your test step and write the time in Properties step with iteration number

4. at the end calculate the time difference.

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Community Hero

Re: Getting the milliseconds between 2 TestSteps

You try load test which shows time


Regards,
Rao.
Highlighted
New Contributor

Re: Getting the milliseconds between 2 TestSteps

@HimanshuTayal 

That is the closest to what I've actually done.

 

for every loop I write the times in a custom property with an iteration in the property name (StartTime1, EndTime1)

The last step of the TC is a groovy script that logs all of the start and end time into a single text file which I import in Excel to parse and get results.

 

I was hoping for soapui to get the final answer for this test but after all that research and the suggestions here, I think that only excel can offer me the answer I seek.

 

Thanks to you two for the help.

View solution in original post

Highlighted
Community Hero

Re: Getting the milliseconds between 2 TestSteps

It seemed that it has not tried what was suggested which gives out of the box.
The way it was shown in the attached screen shot of previous response shows the time take for each step.
And load test step would show time take for each step.


Regards,
Rao.
Highlighted
New Contributor

Re: Getting the milliseconds between 2 TestSteps

@nmrao I know the time is shown and I could get the information I want from that but the goal is to automate the process.

If I need to take note of the times and calculate manually, it defeats the purpose of automation.

I also dont want the time for each step but the time between 2 specific teststeps.

Highlighted
Community Hero

Re: Getting the milliseconds between 2 TestSteps

Not sure how you want or process after getting the required.

You may want give it a try load test and will be more clear.


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors