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.
1 REPLY 1
Community Manager

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

Thanks for sharing the sample, Lucian!

 

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

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

Join the September Hub-bub to show off, learn and win
New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win