0
我是来自postman的api测试新手。我经历了几篇关于 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;
}
给出无论上述测试程序是正确的。? 在调用post请求并针对上述模型的部门控制器获取请求时,测试所有东西。