Forum Discussion
HimanshuTayal
5 years agoCommunity Hero
Not everytime but once i explored and then used Event Handler in below scenario:
We were having 1000+ test cases and the Automation suite was too old in those 1000+ test cases 500+ test cases were having DB connection, in starting everything was fine but one day DB team told us that we are creating lot of open connections, so we start exploring why our scripts are not closing
Everything was fine but connection was not getting closed for Failed scripts, so we updated our scripts by use of Event Handler.
What we did is create DB object on TestSuiteRunListner.beforeTestCase
import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; def url = context.expand( '${mongourl}' ) MongoClientURI client = new MongoClientURI(url); MongoClient mongoClient = new MongoClient(client); context.setProperty("mongoClient", mongoClient) log.info "executed before"
and close db on TestSuiteRunListner.afterTestCase
context.mongoClient.close() log.info "Executed After"
That was my real case example, which help me in creating lesser connection every time our Project gets executed.
Related Content
- 5 years ago
Recent Discussions
- 5 days ago
- 10 days ago