markc_1
16 years agoNew Contributor
Running test steps manually after the test suite has run in Java
Howdie,
A bit of background:
I have created a test framework in Java that dynamicly runs tests that are specified in a soapui project file with values specified in a set of XML files.
This all works perfectly well with one problem, the service I am testing is a database, each test requires the database to be cleared of all objects after each test. This clearing does not always happen due to assertions failing in a test step. For example:
CreateDBObject - I call the create service with an invalid tag e.g. a date tag set to "abc", this should fail, but lets say that the validation has not been implemented server side, so this succeeds and creates a DBObject and returns a Success response. However there is an assertion on the response expecting it to fail, at this point the Java program stops executing the test suite and generates an error report.
TransferDBObjectID - The id from the CreateDBObject is transfered into a property
RetrieveDBObject - The object is retrieved
DeleteDBObject - Delete the object thus cleaning the database
Due to the fact that the CreateDBObject fails to validate the error ab object is created, but it is never deleted due to the fact that the soap runner in java stops after a failed assertion.
Since the class that runs these tests implements TestRunListener there is an afterRun (which is used to generate the report generally), but I also use it to run an extra couple of soap steps, the RetrieveDBObject and DeleteDBObject steps manually.
This is where my problem arises, these steps do not seem to work, I am confused as to why. The only reasons I can come up with is that either the properties used in those test steps are not set because they are run manually (I don't think this is the case as I think I have checked this theory) or the test suite has completed before afterRun is called and thus the two steps run in afterRun are run in a fresh test suite and thus cannot transfer the Id from the previous test suite.
Any ideas on what is wrong here, or how I can accomplish a "clean database" functionality after each test suite is run, no matter if the suite passes or fails ?
Thanks
(This post may be confusing to read, if so I can try to explain more)
Mark
A bit of background:
I have created a test framework in Java that dynamicly runs tests that are specified in a soapui project file with values specified in a set of XML files.
This all works perfectly well with one problem, the service I am testing is a database, each test requires the database to be cleared of all objects after each test. This clearing does not always happen due to assertions failing in a test step. For example:
CreateDBObject - I call the create service with an invalid tag e.g. a date tag set to "abc", this should fail, but lets say that the validation has not been implemented server side, so this succeeds and creates a DBObject and returns a Success response. However there is an assertion on the response expecting it to fail, at this point the Java program stops executing the test suite and generates an error report.
TransferDBObjectID - The id from the CreateDBObject is transfered into a property
RetrieveDBObject - The object is retrieved
DeleteDBObject - Delete the object thus cleaning the database
Due to the fact that the CreateDBObject fails to validate the error ab object is created, but it is never deleted due to the fact that the soap runner in java stops after a failed assertion.
Since the class that runs these tests implements TestRunListener there is an afterRun (which is used to generate the report generally), but I also use it to run an extra couple of soap steps, the RetrieveDBObject and DeleteDBObject steps manually.
This is where my problem arises, these steps do not seem to work, I am confused as to why. The only reasons I can come up with is that either the properties used in those test steps are not set because they are run manually (I don't think this is the case as I think I have checked this theory) or the test suite has completed before afterRun is called and thus the two steps run in afterRun are run in a fresh test suite and thus cannot transfer the Id from the previous test suite.
Any ideas on what is wrong here, or how I can accomplish a "clean database" functionality after each test suite is run, no matter if the suite passes or fails ?
Thanks
(This post may be confusing to read, if so I can try to explain more)
Mark