
// http://www.thinkermaster.com/test/carInfo
// {"code":200,"data":{"brandName":"BMW","factoryName":"BoLin","nation":"German","price":100000.0},"message":"OK"}
// 断言:响应时间小于200ms
pm.test('Response time is less than 200ms', function () {
pm.expect(pm.response.responseTime).to.be.below(200);
})
// 断言:内容包含某个字符串
pm.test('Body matches string', function () {
pm.expect(pm.response.text()).to.include('BoLin');
})
// 断言:某一字段的值
pm.test('json value check', function () {
var jsonData = pm.response.json();
pm.expect(jsonData.data.brandName).to.eql('BMW');
})
// 断言:状态码
pm.test('Status code is 200', function () {
var jsonData = pm.response.json();
pm.expect(jsonData.code).to.eql(200);
})
// 断言:状态码
pm.test('Status code is 200', function () {
pm.expect(pm.response.to.have.status(200))
})
// 断言:header
pm.test("Content-Type is present", function () {
pm.expect(pm.request.headers.get('User-Agent')).to.exist;
pm.expect(pm.response.headers.get('Server')).to.exist;
});