Knowledge Base Article

Groovy script to log the test execution duration for every test suite/test case

Solution

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."
	}
}

 

Published 3 years ago
Version 1.0

Was this article helpful?

No CommentsBe the first to comment