Execute Steps Sequentially
I have a Project with 2 test cases in it.
Set Up
Test Case 1 has 3 Steps(Groovy Scripts). Each of these steps creates a different type of xml.
Test Case 2 has only one Groovy Script that has connection properties to send the above xmls to the desired destination.
Flow
- In the Test Case 1, for each test step, at the end of the script I am setting the properties like end point, test step name, xml to Test Case 2.
- When Test Case 2 is called from Test Case 1 - Step 1, Test Case 2's Step looks at its properties like the end point & xml and send them to the destination.
- I am running just Test Case 1 and not the Test Suite as I don't want to call the Connections again as a separate test.
- The 3 Steps in Test Case 1 execute sequentially one after the other making subsequent calls to the Test Case 2 - Step.
Problem
- When I check my Application Logs, I can see that only the Test case 1 --> Step 2's XML is sent thrice to the application.
- When I checked the properties of the Test Case 2 after the Test case execution finished, I can see that the properties are set correctly.
- The expected outcome I want is --> Each Step's XML should be sent separately to the Application, not just one step's XML thrice.
i.e When Test Case 1 - Step 3 executed those properties written to Test Case 2 are perfectly saved.
Not sure why the Test Case 2 is not reading those properties correctly.
Sample Code :
In Test Case 1 I am using the below code in each steps
def tc = testRunner.testCase.testSuite.getTestCaseByName("Test Case 2")
tc.setPropertyValue('TestCase', testRunner.runContext.currentStep.name) //This was just to write to log
tc.setPropertyValue('Send',"QueueName")
tc.setPropertyValue('updated', updated) //updated holds the xml from Test Case 1's steps each time. So when TC1-Step1 executes, it updates the property called "updated" with its xml. When TC1-Step2 exevutes, it updates the same property next time.
testRunner.runTestStep( project.testSuites['Test Suite'].testCases['Test Case 2'].testSteps['Test Step 2'] )
In Test Case 2, I am using the below lines to read from its properties.
def updated = testRunner.testCase.getPropertyValue('updated')
TextMessage msg = queueSession.createTextMessage(updated)
How can I run the steps in Test case 1, so that they each can make a call passing their properties to Test Case 2, so that test case 2 can use those properties to send them tot the target.
I figured out the solution myself.
Instead of setting properties(which need to be read from another test case) at Test Case Level, I set them at Project level/.
def tc = context.testRunner.testCase.testSuite.project
tc.setPropertyValue('TestCase', testRunner.runContext.currentStep.name)