当我通过放心(Examples 关键字)运行 POST 调用时,第一个数据集请求运行良好,但第二个数据集值变得混乱
当我通过放心框架(Cucumber Examples 关键字)运行 POST 调用时,第一个数据集请求运行良好,但使用第二个数据集时,第一个数据集和第二个数据集值都会合并。如何纠正这个问题?
功能文件:
使用“名称”和“配置文件类型”给出配置文件详细
信息示例: |名称 |轮廓类型 |
| Davian | ADULT |
| Kavian | ADULT |
步骤定义:
public void profile_details_with_and(String name, String profiletype) throws IOException {
config.setProperty("Base.properties");
testservice.setBaseURI();
testservice.addQueryParam("at", config.getConfig().getProperty("at"));
testservice.addHeaderCookie("COOKIE",config.getConfig().getProperty("COOKIE"));
testservice.callRequestSpec();
testservice.formParam("profilePic","default");
testservice.formParam("locale","en");
testservice.formParam("name",name);
testservice.formParam("profileType",profiletype);
}
public void formParam(String key, String value) throws IOException{
requestSpec = given().spec(setBaseURI()).contentType(ContentType.URLENC.withCharset("UTF-8")).formParam(key, value);
}
日志输出:
Form params:
profilePic=[default, default]
locale=[en, en]
name=[Davian, Kavian]
profileType=[ADULT, ADULT]
When I run the POST call through Rest assured framework(Cucumber Examples keyword), first dataset requests run fine but with the second dataset, both first dataset and second dataset values are getting merged. How can this be rectified?
Featurefile:
Given profile details with "name" and "profiletype"
Examples:
| name | profiletype |
| Davian | ADULT |
| Kavian | ADULT |
Stepdefinition:
public void profile_details_with_and(String name, String profiletype) throws IOException {
config.setProperty("Base.properties");
testservice.setBaseURI();
testservice.addQueryParam("at", config.getConfig().getProperty("at"));
testservice.addHeaderCookie("COOKIE",config.getConfig().getProperty("COOKIE"));
testservice.callRequestSpec();
testservice.formParam("profilePic","default");
testservice.formParam("locale","en");
testservice.formParam("name",name);
testservice.formParam("profileType",profiletype);
}
public void formParam(String key, String value) throws IOException{
requestSpec = given().spec(setBaseURI()).contentType(ContentType.URLENC.withCharset("UTF-8")).formParam(key, value);
}
Logs Output:
Form params:
profilePic=[default, default]
locale=[en, en]
name=[Davian, Kavian]
profileType=[ADULT, ADULT]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为每个示例编写一个单独的方案。然后,您可以隔离这个问题。通常,即使这意味着要进行一些重复,也可以使您的方案保持简单。您无需使用示例组或方案大纲即可有效地进行CUKE。
Write a seperate scenario for each example. Then you can isolate the issue. In general keep you scenarios simple even if it means a bit of repition. You don't need to use example groups or scenario outlines to cuke effectively.