???soapUI????REST????1??
???????????? ???????[ 2017/6/15 11:16:57 ] ?????????????????? ???????
????REST ???????
????REST??Representational State Transfer???? Roy Fielding ????? 2000 ???????????μ???????????????????resource??????????? HTTP?? URI??XML ??? HTML ??????????Э?????????????????????????? ??Щ?????????????????????????????????????? HTTP Э??? GET??POST??PUT ?? DELETE ??????REST ???????????????????
?????????е?????????????????????resource????
??????????????????????????resource identifier????
?????????????????????generic connector interface??????????в?????
???????????????????????????????
???????е???????????????stateless????
????REST ????RESTful Service?????????? HTTP ?? REST ?????????? Web ??????????????????????????resource?????????????????????????????????????? :
???????? Web Service ?? URI???磺http://example.com/resources??
????Web Service ?????????? MIME ??????磺JSON?? XML?? YAML ???
????Web Service ??? HTTP Э????????????? GET?? POST?? PUT?? DELETE??
????????????е? Web ?????????? SOAP ?? XML-RPC?? REST ????????????????????? HTTP Э??????????????????? Cache ???????????? ???????Ч?????????????????? SOAP Э?顣 ????????????????? soapUI ????????? Web ????
????soapUI ????
???????? Web ???????????????? ??????????????????????????????????? soapUI ??????????????????????ò??????д?????????????? ?????????????????????????????????ù?????????Э?飬????????????????????е??????С?
????soapUI ???????????????????檔 ???????????????soapUI ???????????????棬?????????????????????? soapUI ?????????????????????????????????????? ?????????????????soapUI ???????????? ???繦???????????????????????????? soapUI ????????????????? 100 ??Σ??????????? Web ???????????? Web ??????????? ?????????????????? SOAP ?? Web ???????????? REST ???? Web ?????????????????????
????soapUI ???? Java ????????????????????????????????? soapUI ?? ?????????????????? ( ?????????? Window ?汾 3.0.1)??????????ɡ???e?????У?????????? soapUI ??????? JRE1.6 ?汾?????????????????????? JAVA_HOME ???????????? JRE ????????? PATH ???????? JRE1.6 ?? bin ?????????
????REST ??????
???????????????????????????? soapUI ?? REST ??????????????????????????????? (http://www.example.com) ????????????????????????Щ REST ???????????????ó?????á? ??????????????????????? soapUI ???в?????????????Щ REST ????????????????????????????? 3 ???????鼮?б???鼮??????????????? 3 ?? REST ????????????? REST ??????????? HTTP ?????????????????
?嵥 1. ?鼮?б? application/json
{"books":
[
{"book":
{
"id":
"1234"??
"name":
"book1"??
"price":
29
}}??
{"book":
{
"id":
"5678"??
"name":
"book2"??
"price":
18
}}
]}
?嵥 2. ?鼮?б? text/xml
<bookes>
<book>
<id>1234</id>
<name>book1</name>
<price>29.0</price>
</book>
<book>
<id>5678</id>
<name>book2</name>
<price>18</price>
</book>
</bookes>
?嵥 3. ?鼮???? application/json
{
"id":
"1234"??
"name":
"book1"??
"description":
"this is book 1"??
"author":
"author1"??
"price":
29??
"comments":
[
{"comment":
{
"user":
"user1"??
"content":
"good book"
}}??
{"comment":
{
"user":
"user2"??
"content":
"not bad"
}}
]
}
?????? soapUI ?н???????????
????????????
???????????????????????????????????? soapUI ?е????????soapUI ?? REST ???????????????????????ν????? ? 1???????????????2?Σ?
??????????壺λ????? (BookStoreTest)??????????????????????塣
????REST ?????壺???????????? REST ???????????飬??????????????????????? BookStoreServie
????REST ??????壺????????????????????URI?? ??????????
????REST ???????壺?????????????? (GET??POST??PUT??DELETE ?? )??? 1 ?е???????? GetBookList
????REST ?????????壺????????????????????????????????????? GetBookListRequest????Щ????????????????? soapUI ????????е???????????????÷??????????????? Accept ?????????? Header ?????????????????????????????????н?????????????????????????????? - ?????????????????????????á?
??????? ????????? ???????? bookstore-soapui-project.zip ??????????????????????????????????????н????????? zip ????????????? xml ???????????? soapUI ?? File->import project ????????????????????С?
????? 1. soapUI ?е??ν?
???????????????????????????????ν???
????TestSuite???????? Junit ?е????????????п???????? TestCase
????TestCase???????????? TestStep
????TestStep????? TestCase ?????????? TestStep??TestStep ?ж????????????????????????? REST ?????????????????? Groovy ??????????????????????????????? TestStep ?????????????????????????????????????? step ????????????? step?? ???????????С?
????soapUI ????????????????????????????????????????????????????? groovy ????????? soapUI ?е?????????????? REST request/response?? ????????????????
????? 2. TestCase ????
????????????????
????????????????????????? soapUI ?д?????????????????? ???????????????????????????????????????????? 3??????????????鼮?б? REST ???????裺
????1. ????????? BookStoreTest ?????
????2. ?????????????????"New Rest Service"?????????????? Service Name(BookStoreService) ?? Endpoint(http://localhost:9080)
????3. ??"BookstoreService"????????????“New Resource”?? ???????????? Resource Name(BookList) ?? Resource Path (/books)????? OK
????4. ????????????????? Method Name: GetBookList??HTTP Method ??????? GET?? ??? OK
???????? REST ??????????? TestCase???????????????
???????????????????£?
????(1). ????????? REST ???????籾???е?"BookStoreService"?? ???"Generate TestSuite"
????(2). ????????????У????????????? ???"OK"
????(3). ???????? ?? ????"BookStoreService TestSuite"?? ???"OK"???ɡ?
????????????????????£?
????(1). ?????"BooksStoreTest"????????????“New TestSuite”?? ????????????"BookStoreService TestSuite"
????(2). ?? BookStoreService TestSuite ????????? ???"New TestCase"?? ????????????"BookList TestCase"
????(3). ??????????????????? BookList TestCase?? ??“Test Steps”??????????? Add Step->Rest Test Request
????(4). ???????????????? GetBookListRequest_XML
??????????? TestCase ?? ? 4?????????????????м??? Assertion ?????н?????????????????????????????????
????? 4. REST TestCase
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11