cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing is caring - groovy script to log the test execution duration for every test suite/test case

Highlighted
Community Hero

Sharing is caring - groovy script to log the test execution duration for every test suite/test case

The following is a TearDown script to log test execution duration for every test suite and test case.

 

// Define variables for holding test suites, test cases and test steps
def testSuites
def testCases

// Get the list of test suites
testSuites = runner.getResults() 

// Iterate through each test suite
testSuites.each() {
	log.info "----------------------------------------"
	log.info "The test suite " + "'" + it.getTestSuite().getName() +"'" + " took " + it.getTimeTaken() + "ms to finish."
	log.info "The following are the contained test cases along with their durations..."

	// Get all the test cases and iterate through them
	testCases = it.getResults()
	testCases.each() {
		log.info "...the test case " + "'" + it.getTestCase().getName() +"'" + " - " + it.getTimeTaken() + "ms."
	}
}


If my answer helped please click on the 'Accept as Solution' button.
Tags (1)
1 REPLY 1
Highlighted
Community Manager

Thanks for sharing the sample, Lucian!

 

Community, has anyone already tried the sample? Any questions/suggestions/comments?

---------
Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors