简体   繁体   English

我们如何在 Serenity BDD API 测试中同时使用“request.headers”和“requestpathParam”?

[英]How do we use both 'request.headers' and 'requestpathParam' in Serenity BDD API testing?

This code doesn't work此代码不起作用

sam.attemptsTo(
    Get.resource("/byName/{search_text}").with(request -> request.headers(header))
                        .with(request -> request.pathParam("search_text",search_item))
    );

But below code works fine但下面的代码工作正常

sam.attemptsTo(
    Get.resource("/byName/Apple").with(request -> request.headers(header))
);

The response status code is 400 in case of using both the 'request.header' and 'request.pathParam' but response in case of sending only then header I get 200 Ok status response code.如果同时使用“request.header”和“request.pathParam”,则响应状态代码为 400,但在仅发送 header 的情况下响应,我得到 200 Ok 状态响应代码。

The server was returning a 500 error whenever there was a non matching /unavailable data in the back-end.只要后端有不匹配/不可用的数据,服务器就会返回 500 错误。 So there was nothing wrong with code syntax or semantic.因此,代码语法或语义没有任何问题。 The parameter was the issue.参数是问题。

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

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