Using variables and running tests with driver script causes fails
I am trying (maybe foolishly?) to write a Groovy script to run a series of test cases in a test suite.
The script would/should be able to
1) get all the testnames to run in the test suite,
2) loop through execute each test in order found in suite
A- execute any SQL queries defined in testcase properties and create the dynamic property/value pairing at testcase level
3) loop through steps in each called test run while utilizing any defined variables(properties) referenced for input or assertions
4) produce informative log on each test/step so others know what was test
It is these last two part that have gotten me in a knot--I can not seem to get the test steps to execute and use the referenced variables (either as part of the request or part of the assertion) - for example I may run a SQL - it retrieves an OrderKey - which I write as a Property at the testcase level - then I try to sub in that value using the parameter in the API Request and subbing in ${#TestCase#OrderKey} - it works if I run it manually and it uses the value I manually put in the property but when I run the script to get it to execute this step it fails even though the SQL has run and defined the value in the test case property (OrderKey) successfully - it fails to make the request and throws an error. If I manually execute it again at this point with the retrieved value from the SQL - it works. The same goes for the Assertions - if I reference a property - it fails when run through the script (which I removed the variablized "submission" value and hardcoded it) - but if I click the Request to run manually with same setup - it works. Sooo...what's the deal?
the command I use to run the step is --> (beginning of the loop)
def Steps = it.getTestStepList()
Steps.each //loop thru each step in test case as found by previous command
{
tstep = tcase.getTestStepByName(it.Name);
status = tstep.run(testRunner,context);
and then the rest of the steps follow - does something need to be done to enforce the variablization in the script?
Big question number 2 - can Assertion scripting be done in a regular Groovy script or do you have to go to the Request and bring up the Script Assertion file and code it there? If it can be done directly in a standalone Groovy script - an example would be cool too! Everytime I try I get that the messageExchange object is invalid or unavailable...
Any help is appreciated - but keep in mind - I am a NEWBIE so please don't assume I know anything....THANKS!