简体   繁体   English

状态代码与实际状态代码不匹配

[英]Status code doesn't match actual status code

I'm having this errors for all of my test cases . 所有的测试用例都遇到这个错误。 Please, help to find out what's wrong? 请帮忙找出问题所在? I'm new to testing, so sorry if it's a silly question. 我是测试的新手,如果这是一个愚蠢的问题,请原谅。

java.lang.AssertionError: 1 expectation failed. java.lang.AssertionError:1个期望失败。 Expected status code <200> doesn't match actual status code <301>. 预期状态码<200>与实际状态码<301>不匹配。

@Test (priority=1)
public static void authSuccess(){
    String id = "xxxxxxxxxx";
    given().
            param("id",id).
            when().
            post("/auth").
            then().
            statusCode(200).
            body("content.id", equalTo(id));
}

@Test (priority=2)
public static void authFail(){
    String id = "xxxxxxxxxx";
    given().
            param("id", id).
            when().
            post("/auth").
            then().
            statusCode(400).
            body("errors[0]", equalTo("Incorrect ID"));
}

Hope you have tested in Postman/SoapUI before attempting into automation tests. 希望您在尝试自动化测试之前已经在Postman / SoapUI中进行了测试。

And you got 200 in postman as well. 而且您还有200名邮递员。

Couple of pointers 几个指针

  1. Check you are using same methods eg., get/post. 检查您是否使用相同的方法,例如获取/发布。
  2. Double check the endpoints you are using 仔细检查您正在使用的端点
  3. Make sure your headers and parameters are right between rest assured and postman. 确保您的标题和参数在放心和邮递员之间。

Hope this helps out! 希望这会有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM