SoapUI 使用心得

如何使用script validation 验证消息

assertmessageExchange.getResponseContentType().contains("application/json")

assertmessageExchange.responseHeaders["#status#"].toString().contains("304")

http://www.soapui.org/Functional-Testing/script-assertions.html

ThemessageExchange object available in the script exposes a bunch of propertiesrelated to the last request/response messages (check out theJavadoc), lets look at some simple examples:

1. Validate the content of an HTTP Headerin the response

view sourceprint?

// check for the amazon id header

assertmessageExchange.responseHeaders["x-amz-id-1"]!= null

2. Validate a certain response time

view sourceprint?

// check that response time is less than400 ms

assertmessageExchange.timeTaken< 400

3. Validate the existence of an attachmentin the response

view sourceprint?

// check that we received 2 attachments

assertmessageExchange.responseAttachments.length== 2

4. Validate the existence of a specificXML element in the response

view sourceprint?

// check for RequestId element inresponse

defholder = newXmlHolder(messageExchange.responseContentAsXml )

assertholder["//ns1:RequestId"]!= null

JavaDoc 

http://www.soapui.org/apidocs/com/eviware/soapui/model/iface/MessageExchange.html

java.lang.String

getEndpoint()

 java.lang.String[]

getMessages()            

 ModelItem

getModelItem()          

 Operation

getOperation()            

 StringToStringMap

getProperties()          

 java.lang.String

getProperty(java.lang.String name)             

 byte[]

getRawRequestData()             

 byte[]

getRawResponseData()            

 Attachment[]

getRequestAttachments()             

 Attachment[]

getRequestAttachmentsForPart(java.lang.String partName)             

 java.lang.String

getRequestContent()             

 java.lang.String

getRequestContentAsXml()            

 StringToStringsMap

getRequestHeaders()           

 Attachment[]

getResponseAttachments()            

 Attachment[]

getResponseAttachmentsForPart(java.lang.String partName)              

 java.lang.String

getResponseContent()             

 java.lang.String

getResponseContentAsXml()             

 StringToStringsMap

getResponseHeaders()            

 long

getTimestamp()            

 long

getTimeTaken()            

 boolean

hasRawData()            

 boolean

hasRequest(boolean ignoreEmpty)            

 boolean

hasResponse()            

 boolean

isDiscarded()

 

How to enlarge SoapUI JVM memory size.

1.      If you want toenlarge UI part, should updatesoapui.bat in {Program Files}\eviware\soapUI-4.0.0\bin is forSoapUI UI part like below.

Change setJAVA_OPTS=-Xms128m -Xmx1024m -Dsoapui.properties=soapui.properties"-Dsoapui.home=%SOAPUI_HOME%\" to

setJAVA_OPTS=-Xms2048m -Xmx2048m -XX:MaxNewSize=1024m -XX:MaxPermSize=1024m-Dsoapui.properties=soapui.properties "-Dsoapui.home=%SOAPUI_HOME%\"

2.      If you want toenlarge command part, should updatetestrunner.bat in {Program Files}\eviware\soapUI-4.0.0\bin isfor SoapUI UI part like below.

Change setJAVA_OPTS=-Xms128m -Xmx1024m -Dsoapui.properties=soapui.properties"-Dsoapui.home=%SOAPUI_HOME%\" to

setJAVA_OPTS=-Xms2048m -Xmx2048m -XX:MaxNewSize=1024m -XX:MaxPermSize=1024m-Dsoapui.properties=soapui.properties "-Dsoapui.home=%SOAPUI_HOME%\"

 

TestRunnerparameters

Running functional testsfrom the command-line is straightforward using the included testrunner.bat/.shscript, which takes a number of arguments to control which tests to run,output, etc:

  • e : The     endpoint to use when invoking test-requests, overrides the endpoint set in     the project file
  • h : The     host:port to use when invoking test-requests, overrides only the host part     of the endpoint set in the project file
  • s : The     TestSuite to run, used to narrow down the tests to run
  • c : The     TestCase to run, used to narrow down the tests to run
  • u : The     username to use in any authentications, overrides any username set for any     TestRequests
  • p : The     password to use in any authentications, overrides any password set for any     TestRequests
  • w : Sets     the WSS password type, either 'Text' or 'Digest'
  • d : The     domain to use in any authentications, overrides any domain set for any     TestRequests
  • r : Turns     on printing of a small summary report (see below)
  • f :     Specifies the root folder to which test results should be exported (see     below)
  • j : Turns     on exporting of JUnit-compatible reports, see below
  • a : Turns     on exporting of all test results, not only errors
  • o : Opens     the generated report in a browser (soapUI Pro only)
  • i :     Enables soapUI UI-related components, required if you use the UISupport     class for prompting or displaying information
  • t : Sets     the soapui-settings.xml file to use, required if you have custom proxy,     ssl, http, etc setting
  • x : Sets     project password for decryption if project is encrypted
  • v : Sets     password for soapui-settings.xml file
  • D : Sets     system property with name=value
  • G : Sets     global property with name=value
  • P : Sets     project property with name=value,e.g. -Pendpoint=Value1     -PsomeOtherProperty=value2
  • S : Sets     to save the project file after tests have been run
  • I : Do     not stop if error occurs, ignore them
  • R :     Selects which report to generate for the test objects executed, for     example if running the entire project, this could specify the name of a     test-suite-level report that would be generated for each TestSuite. The     report is saved as specified with the -F option to the folder specified     with the -f option. (soapUI Pro only)
  • F : Sets     the format of the report specified with the -R option, for Printable     reports this is one of PDF, XLS, HTML, RTF, CSV, TXT, and XML. For Data     Export this is either XML or CSV (soapUI Pro only)
  • g : Sets     the output to include Coverage HTML reports ( soapUI Pro only )

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值