A quick way to get the duration of a test using Groovy
From a previous test I worked on, I wanted to point out how to record the execution time of a test. It uses the
TimeDuration libraries. Since my API test doesn't run within a Test Suite, it doesn't record the execution time, but it's still possible to get that information using code similar to the following.
import groovy.time.TimeCategory import groovy.time.TimeDuration def timeStart = new Date() //Test Code goes between the Start and Stop definitions def timeStop = new Date() TimeDuration duration = TimeCategory.minus(timeStop, timeStart) log.logWarning("Execution Time: " + duration)
Other articles of interest:
- Adding Timing Flags to Test Cases within Katalon
- Data Driven API Testing with Katalon using Spreadsheet Data
- Show the currently executing Test Case both before and after it runs
- Changing the scope of a variable to be available within a Method
- Output status messages and test information by writing to the Log File Viewer in Katalon Studio
- Marking tests as Passed, Failed or in Error using MarkFailed, MarkPassed, MarkError in Katalon Studio
- Conditional Statements – IF .. ELSE IF in Katalon Studio
- Working with Dates and Date Formatting in Katalon Studio
- To markFailedAndStop or Not To markFailedAndStop?
- Adding Feature Flags to Test Cases