Ado
download:
http://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/ choose to download the latest version of the jar package
start up:
1 : jar package in the local directory where the new json file, you can freely customize the request, respond, optional parameter list: "method", "headers" , "json", "factory", "uri", "text", "cookies "," xpaths "," json_paths "," version "," file "," queries "," path_resource "," forms "
Wherein REQUEST request can be filled :
uri: Request address
method: the type of request (get post)
cookies: cookies with the authentication
headers: request header (Example "content-type": "application / json")
queries: Fill the request parameters, the request type is a get request, using the field
Forms: Fill the request parameters, the request type is a post (a form similar form) is requested, using the field
Json: fill in the request parameters, the data format is json, get, post may be used
file: request parameters, when the package json file (address)
response can be filled:
status: Status Code
text: the text data corresponding to the data
json: json response data to the data format
file: data response is json file (file address)
method = get, the argument submitted with queries, when = post, use forms, otherwise an error
Example:
New File confirmOrder.json, this is the way to post without parameters:
[{ "Description": "New Order acceptance" , "Request" : { "URI": "/ Test / ConfirmOrder" , "Method": "POST" }, "Response" : { "text": "accept contingent ~ " , # returns noon display garbled text, it tells the browser headers plus encoding is GBK " headers " : { " the Content-the Type ":" text / HTML; GBK charset = " } } }]
2 : Start command system, cd to the directory where the jar package, execute the command: java -jar ./moco-runner-0.12.0-standalone.jar http -p 8888 -c confirmOrder.json
The successful implementation will display a custom port number 8888, as:
Because json file defines the url, this time we visit http: // localhost: 8888 / test / confirmOrder can get a custom response returned.
Note :
At this time, the problems encountered: defines the method = can not access the url directly in the browser after post, browser submits that get way, it will be reported 400 errors as:
Solution: Use the postman or jmeter submit a request by post way.
After a successful return follows:
After post add parameters embodiment, the request:
[{ "description" : "新订接受", "request":{ "uri":"/test/confirmOrder", "method":"post", "forms":{ "orderID":"222", "optionID":"111", "env":"uat" } }, "response":{ "text":"接受成功~", "headers":{ "Content-Type":"text/html;charset=gbk" } } }]
Request manner: Fill in form-data parameter, the request
Redirect:
"request":{...},
"redirectTo":“http://localhost:8888/abc.test.com",
"response":{...}