Forum Discussion
3 Replies
Sort By
- GurbakhsishOccasional Contributor
After investing few hours on this topic, I am able to run few scripts in javascript, they are too basic scripts, but can be used to perform subtle actions.
1. Script to run a test step at testcase tear down -Prerequisites - have a test step inside a testcase and disable it, following testcase teardown script will execute the test stepFor me, Add a priority is a test step in the test case, which should return anything positive, and Delete Priority test step is a test step that will be executed at teat down.if( context.expand( "${Add a priority#Response#$.status}" ) > 400 ) {
var s = testRunner.getTestCase().getTestStepByName("Delete Priority").run(testRunner, context).status;
if (s == "OK"){
log.info("Deleted test data - Priority id - "+ context.expand( "${Add a priority#Response#$.data.id}" ));
}}2. Setup script for a testsuiteTo run a testcase at very beginning of a testsuite, which will create some test data. Add that test case to the test suite and disable it.runner.getTestSuite().getTestCaseByName("Setup - Add an article").run(context.properties, false);3. Assert a value from the responsevar total_count = context.expand( "${Retrieve cases#Response#$.total_count}" );
var result = true;
var entry_id,case_id;
for (i = 0;i<total_count;i++){
entry_id = context.expand( "${Retrieve cases#Response#$.data["+i+"].id}" );
case_id = context.expand( "${Add a case#Response#$.data.id}" );
if ( entry_id == case_id){
result = false;break;
}
}
if(result){throw "Assertion Failed"};- rupert_andersonValued Contributor
Hi,
Thanks for sharing that, its quite an interesting topic! :-)
I think you already know all this, but maybe to help others get started with the original post topic:
Thanks,
Rupert
- tona3743New ContributorIt doesn't look like you're gonna get support for this question.
I also can't get even a single line of javascript to work.
They state that javascript was added for these who are used to javascript, but it looks like its easier to learn groovy than make this crappy feature of soapUI work.
Related Content
- 6 years ago
- 6 months ago
Recent Discussions
- 2 days ago