If you want to make an gmongo
connection alive for an entire test suite and then close it in a tear down operation after the entire test suite is executed then, How could we do that?
Currently what am I doing is, I am creating an connection for an particular test step and then after the test step is executed, I close the connection by using the code mongoClient.close()
But now there is a requirement where I need to create the connection before the test suite starts executing, use the same connection throughout the test suite inside the test cases/test steps and then close the connection the connection after the entire test suite gets executed.
Could anyone please tell me how could I do this using Ready!API?
I may sound retard cause I am new to Ready API so please bear with me This is the code that I use to create an Connection to mongo
def dbUser = context.expand( '${#Project#MongoUser}' )
def dbPassword = context.expand( '${#Project#MongoPassword}' )
def dbServer = context.expand( '${#Project#MongoServer}' )
def dbDatabase = context.expand( '${#Project#MongoDatabase}' )
def credentials = MongoCredential.createCredential(dbUser,dbDatabase,dbPassword as char[])
def mongoClient = new MongoClient( new ServerAddress(dbServer),Arrays.asList(credentials) )
context.gmongo = new GMongo( mongoClient )
context.mongoDB = context.gmongo.getDB(dbDatabase)
So i have been using the current code in order to create the connection. Actually I want this as three test suites. The First Test Suite would contain the groovy script to create the connection, The Second Test Suite would contain all of my Test Cases and the Third test suite would contain the mongo close connection script.
We use the Environment values from the properties file. Here the MongoServer has the values of the environment in which the connection is laid
I could not understand @Rao, how did you call the conn variable inside the test cases. Especially the context.testCase.testSuite.db?.connection part. What does the "?" denote and could you please tell me in the above context, how could carry out the process