In the http://www.cnblogs.com/weke/articles/6859021.html, the Mock-server has done
The preliminary introduction, which continues here today to proceed before the introduction, we first look at the previous Mock-server section before writing
A login mock, specific JSON file see the following:
[
{"
request":
{
"method": "Post",
"uri": "/login",
"JSON":
{
"username": "admin" , "
password": "admin",
"Roleid": "
}",
"response":
{
"json":
{
" Username ":" Wuya ","
UserID ":"
token ":" ASDGFHH32456ASFGRSFSS "}}
]
Looking at the above, we can see that such a way is not so friendly, in the UI or interface Automation test, we know
In the mode of TDD, the data is separated, which is also for the convenience of maintenance, for the purpose of the later automation test case extensibility,
And it's easy to maintain, then come down we're going to make a change to the JSON file above, separate the data from the response section and put it
In a file so that we can separate it out, we separate the contents of the response from the Login.json to the Login_response.json
Remember that Login.json and Login_response.json must remain in the same directory, see Login.json content:
[
{"
request":
{
"method": "Post",
"uri": "/login",
"JSON":
{
"username": "admin" , "
password": "admin",
"Roleid": "
}",
"response":
{
"file": "Login_ Response.json "
}
}
]
See the contents of the Login_response.json file:
{"
username": "Wuya",
"UserID": "
token": "ASDGFHH32456ASFGRSFSS"
}
After executing the Login.json file, access the interface to see if OK, see the command to execute the Login.json file:
Use Postman to view the interface, see whether OK, see the following screenshot:
Below we carry on a business, is to enter a license plate number, inquire the car brand to show the length, and its parking expenses, direct in Loginjson
The document is perfect, see the perfect content:
[
{"
request":
{
"method": "Post",
"uri": "/login",
"JSON":
{
"username": "admin" , "
password": "admin",
"Roleid": "
}",
"response":
{
"file": "Login_ Response.json "
}
},
{"
request ":
{
" method ":" Post ",
" uri ":"/parkinside ",
"JSON":
{
"token": "ASDGFHH32456ASFGRSFSS",
"VPL": "AJ3585"
}
},
"response":
{"
file" : "Parkinside.json"
}
}
]
See the contents of the Parkinside.json file:
{"
vplinfo":
{"
UserID": "
username": "Wuya",
"VPL":