15 years ago
Disable/Enable Assertion Based on DataSource Property
Hello All,
I have a spreadsheet with all my test data in it. I have created a test case with the following steps:
Test Steps:
1. DataSource -> Loads the data from my spreadsheet
2. Groovy Script -> Going to be used to enable and disable an assertion based on some data from DataSource
3. SubmitCheck-Base -> This a SOAP request test step. I have two assertions I need to dynamically turn on and off based on the data from the DataSource.
4. Result Property Transfer -> This transfers the response from the request to the DataSink
5. DataSink -> Write the entire response payload to a second sheet in my spreadsheet.
6. DataSource Loop -> Goes back to the Groovy Script step as long as there is still data in DataSource rows
In my DataSource spreadsheet I have a column (property) called Assertion. This column is either "accept" or "error". When this value in this column for whatever row the test is on is equal to "accept" then I want my "NoFaultAssertion" to be enabled on the SubmitCheck-Base and I want my "FaultAssertion" to be disabled in the the SubmitCheck-Base. And likewise, if the value in the DataSource is "error" I want "FaultAssertion" enabled and "NoFaultAssertion" disabled.
When I compile this script I get numerous errors. Thoughts?
WsdlTestRequestStep step = ((WsdlTestRequestStep)testRunner.testCase.getTestStepByName("submitCheck-Base"));
WsdlMessageAssertion noFault = ((WsdlMessageAssertion)step.getAssertionByName(NoFaultAssertion))
WsdlMessageAssertion fault = ((WsdlMessageAssertion)step.getAssertionByName(FaultAssertion))
if (${DataSource#Assertion} = "accept") {
noFault.setDisabled(true)
fault.setDisabled(false)
} else if (${DataSource#Assertion} = "error") {
noFault.setDisabled(false)
fault.setDisabled(true)
} else {
noFault.setDisabled(false)
fault.setDisabled(false)
}
I have a spreadsheet with all my test data in it. I have created a test case with the following steps:
Test Steps:
1. DataSource -> Loads the data from my spreadsheet
2. Groovy Script -> Going to be used to enable and disable an assertion based on some data from DataSource
3. SubmitCheck-Base -> This a SOAP request test step. I have two assertions I need to dynamically turn on and off based on the data from the DataSource.
4. Result Property Transfer -> This transfers the response from the request to the DataSink
5. DataSink -> Write the entire response payload to a second sheet in my spreadsheet.
6. DataSource Loop -> Goes back to the Groovy Script step as long as there is still data in DataSource rows
In my DataSource spreadsheet I have a column (property) called Assertion. This column is either "accept" or "error". When this value in this column for whatever row the test is on is equal to "accept" then I want my "NoFaultAssertion" to be enabled on the SubmitCheck-Base and I want my "FaultAssertion" to be disabled in the the SubmitCheck-Base. And likewise, if the value in the DataSource is "error" I want "FaultAssertion" enabled and "NoFaultAssertion" disabled.
When I compile this script I get numerous errors. Thoughts?
WsdlTestRequestStep step = ((WsdlTestRequestStep)testRunner.testCase.getTestStepByName("submitCheck-Base"));
WsdlMessageAssertion noFault = ((WsdlMessageAssertion)step.getAssertionByName(NoFaultAssertion))
WsdlMessageAssertion fault = ((WsdlMessageAssertion)step.getAssertionByName(FaultAssertion))
if (${DataSource#Assertion} = "accept") {
noFault.setDisabled(true)
fault.setDisabled(false)
} else if (${DataSource#Assertion} = "error") {
noFault.setDisabled(false)
fault.setDisabled(true)
} else {
noFault.setDisabled(false)
fault.setDisabled(false)
}