【问题标题】:Test REST API using Rest Assured Get type returning 400 status code使用返回 400 状态代码的 Rest Assured Get 类型测试 REST API
【发布时间】:2019-11-20 02:01:19
【问题描述】:

我可以通过邮递员客户端测试我的 REST API 并给我预期的响应。但是,当我尝试通过 junit 进行测试时,它会给出 400 个状态码

根据有效负载,内容类型为 application/json

final static String ROOT_URI = "http://localhost:7000/employees";

@Test
public void simple_get_test() {
    Response response = get(ROOT_URI + "/list?emp=100");
}

我错过了什么

【问题讨论】:

    标签: java junit rest-assured


    【解决方案1】:

    尝试使用 RestAssured.port = 7000 设置端口并将其从 URI 中删除。如果您在代码之外发布响应消息会很有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-08
      • 2021-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-16
      • 2021-06-10
      • 1970-01-01
      相关资源
      最近更新 更多