【发布时间】:2017-05-19 17:34:44
【问题描述】:
我是 postman 的 api 测试新手。我浏览了几篇关于 api 测试。但我不知道我们可以做多深的测试。 另外我们如何为发布请求编写测试。我有以下部门模式类 来自我的网络 API。
[Key]
public int DepartmentId { get; set; }
[Required]
[Display(Name ="Department Name")]
public string DepartmentName { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
我使用的示例获取请求如下所示
var body = JSON.parse(responseBody);
if(!body.DepartmentId)
{
tests["department id must exists in response"]=true;
}
else
{
tests["department id exists in response"]=true;
}
if(typeof body.DepartmentName !='string')
{
tests["department name must be type string"]=true;
}
if(responseCode.name.has("OK"))
{
tests["Status code name has string OK"] = true;
}
上述测试程序是否正确。? 对于上述模型,在调用发布请求和获取针对部门控制器的请求时要测试的所有内容。
【问题讨论】:
标签: testing asp.net-web-api2 postman