RohitBBorse
15 years agoContributor
Saving script assertion result to a path as specified.
Hi,
I have a script assertion applied to each test request.
I wanted to save the result of this script assertion to a root folder path as specified in Launch TestRunner -> Reports -> Root Folder
If I launched test runner at project level, script assertion result should be saved in a path as specified in root folder of Project ->.Launch TestRunner -> Reports -> Root Folder.
Similarly, this should happen for test suite and test case if launched test runner for that particular level.
How I can achieve this with groovy.
Below is a groovy script in script assertion.
Thanks
Rohit Borse
I have a script assertion applied to each test request.
I wanted to save the result of this script assertion to a root folder path as specified in Launch TestRunner -> Reports -> Root Folder
If I launched test runner at project level, script assertion result should be saved in a path as specified in root folder of Project ->.Launch TestRunner -> Reports -> Root Folder.
Similarly, this should happen for test suite and test case if launched test runner for that particular level.
How I can achieve this with groovy.
Below is a groovy script in script assertion.
import org.apache.commons.codec.binary.Base64
teststep=context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()
Severity=context.expand('$'+"{"+teststep+"#Response#//*:Notifications/*:Severity}")
b64 = new Base64()
if (Severity == "SUCCESS"||"WARNING"||"NOTE")
{
LBL=context.expand('$'+"{"+teststep+"#Response#//*:Label/*:Parts/*:Image}")
LblImgType = context.expand('$'+"{"+teststep+"#Request#//*:LabelSpecification/*:ImageType}")
LblDcdBytes = b64.decode(LBL.getBytes())
FileOutputStream LabelImage = new FileOutputStream(new File(""+context.expand('${#TestSuite#LabelPath}')+""+teststep+"."+LblImgType+""));
LabelImage.write(LblDcdBytes);
LabelImage.flush();
}
Thanks
Rohit Borse