您的位置:首页 > 产品设计 > UI/UE

Some tips about SoapUI project

2017-02-27 00:00 288 查看
摘要: 开发SoapUI项目中的一些小经验

1. Test Project and Test Suite name cannot contain blank space.

This will cause many TestSuites error if the project was built on Jenkins.

2. Post body in HTTP request cannot contain charactor '&' .

If it contains '&', the HTTP response will return error information :



3. Post body in HTTP request cannot contain charactor '%' .

If it contains '%', the HTTP response will return error information :



4. Get active environment via groovy script :

log.info testRunner.testCase.testSuite.project.getActiveEnvironment().getName()

5. Set active environment via groovy script :

testRunner.testCase.testSuite.project.setActiveEnvironment("Live")

6. Get current project's workspace path: ${projectDir} .

The property has been invoked.

7. Get one TestStep's response:

def response = testRunner.testCase.testSteps["InitCase"].testRequest.response.contentAsString

def response = context.expand('${InitCase#Response}')

def response = messageExchange.getResponseContent()

8. Set TestStep's request headers:

def headerMap = new StringToStringMap()

headerMap.put("X-API-UserId",'${#Project#X-API-UserId}')
headerMap.put("Accept-Encoding", "deflate")

testRunner.testCase.testSteps["InitCase"].testRequest.setRequestHeaders(headerMap)

9. Set property value into TestSuite:

testRunner.testCase.testSuite.setPropertyValue(propertyName, propertyValue)

That's the same logic for setting property value into TestStep and Project.

10. Get TestStep list of one TestRequest type:

testRunner.testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.class)

Test Step Type有一下几种:

HttpTestRequestStep

JdbcRequestTestStep

ManualTestStep

RestTestRequestStep

WsdlDelayTestStep

WsdlGotoTestStep

WsdlGroovyScriptTestStep

WsdlMockResponseTestStep

WsdlPropertiesTestStep

WsdlRunTestCaseTestStep

WsdlTestRequestStep

WsdlTestStep

11. Goto one TestStep by Name :

testRunner.gotoStepByName("TestStepName")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息