zoukankan      html  css  js  c++  java
  • SoapUI offen used scripts

    【 Groovy Step 】
    
    //get properties from testCase, testSuite and project in groovy step
    def testCaseProperty  = testRunner.testCase.getPropertyValue( "MyProp" )  // testCase property
    def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )  // testSuite property
    def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )//project property
    
    // set properties to testCase,testSuite and project in groovy step
    testRunner.testCase.getProperty("MyProp").setValue("MyValue");   // set testCase property
    testRunner.testCase.setPropertyValue("MyProp","MyValue");
    
    testRunner.testCase.testSuite.getPropertyValue( "MyProp" ).setValue("MyValue");  // set testSuite property
    testRunner.testCase.testSuite.setPropertyValue("MyProp","MyValue");
    
    testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" ).setValue("MyValue");  // set project property
    testRunner.testCase.testSuite.project.setPropertyValue("MyProp","MyValue");
    
    
    // get the response content
    String  responseStr = testRunner.testCase.testSteps["MyStep"].testRequest.response.contentAsString;
    // convert the response content to JSON format
    import groovy.json.JsonSlurper;
    JsonSlurper slurper = new JsonSlurper(); Object responseObj = slurper.parseText(responseStr); // run another test step under current test case testRunner.runTestStepByName("MyStep"); // run another test step under another test case
    import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner; def testcase = testRunner.testCase.testSuite.project.testSuites["MyTestSuite"].getTestCaseByName("MyTestCase"); WsdlTestCaseRunner runner = new WsdlTestCaseRunner( testcase,null ); runner.runTestStepByName("AnotherStep"); 【 Script Assertion 】 def number = messageExchange.modelItem.testCase.testSteps["Properties"].getPropertyValue("userId") def testCaseProperty = messageExchange.modelItem.testCase.getPropertyValue("MyProp"); def testSuiteProperty = messageExchange.modelItem.testCase.testSuite.getPropertyValue("MyProp"); def projectProperty = messageExchange.modelItem.testCase.testSuite.project.getPropertyValue("MyProp"); // project property can be also like: def projectProperty = messageExchange.modelItem.project.getPropertyValue("MyProp"); def projectProperty = context.expand('${#Project#MyProp}'); // 注意,用双引号貌似会出错 def testSuiteProperty = context.expand('${#TestSuite#MyProp}'); // get the response content def responseContent = messageExchange.responseContent; // get the response content and convert to JSON format def jsonObj = net.sf.json.JSONSerialize.JSONSerializer.toJSON(messageExchange.responseContent);
  • 相关阅读:
    农村养殖业什么最赚钱?什么养殖项目行情好?
    加盟店可靠吗?如何识破加盟骗局?
    开小店做什么生意好?开小店需要营业执照吗?
    投资小的项目有哪些?投资小项目推荐
    贪心
    关于:Express会被Koa2取代吗?
    关于:Express会被Koa2取代吗?
    关于:Express会被Koa2取代吗?
    关于:Express会被Koa2取代吗?
    剑指offer
  • 原文地址:https://www.cnblogs.com/tomweng/p/5567697.html
Copyright © 2011-2022 走看看