Testing 使用postman进行API测试

Testing 使用postman进行API测试,testing,asp.net-web-api2,postman,Testing,Asp.net Web Api2,Postman,我刚从postman开始接触api测试。我浏览了几篇关于api的博客和文章 api测试。但我不知道我们可以做多深的测试。 还有,我们如何为post请求编写测试。我有下面的部门模式类 从我的web api [Key] public int DepartmentId { get; set; } [Required] [Display(Name ="Department Name")] public string DepartmentName { get; s

我刚从postman开始接触api测试。我浏览了几篇关于api的博客和文章 api测试。但我不知道我们可以做多深的测试。 还有,我们如何为post请求编写测试。我有下面的部门模式类 从我的web 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; }
下面给出了我使用的示例get请求

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请求和get请求时,需要测试哪些内容。

您不必编写两个测试用例来测试+ve和-ve场景。您所需要做的就是编写一个测试用例,它将根据场景通过或失败。例如,让我们考虑一下<强>部门> /强>

测试用例应该是

tests["department id must exists in  response"]= body.DepartmentId? true : false;
根据您的部门id是否存在,您的测试用例将通过(标记为绿色)或失败(标记为红色)

或者,如果您不仅要进行测试,还要设计API并记录它们,那么请查看。它是端到端API设计文档和测试的一个很好的工具