简体   繁体   English

在FitNesse中将HashMap作为参数传递

[英]Pass HashMap as parameter in FitNesse

I am trying to pass a HashMap parameter to the function I am using in Fitnesse. 我试图将HashMap参数传递给我在Fitnesse中使用的函数。 However, nothing is being passed correctly, as i am getting "{}" when remote debugging in eclipse. 但是,没有正确传递任何东西,因为在Eclipse中进行远程调试时出现“ {}”。

Below is the method that I am calling: 下面是我正在调用的方法:

public String issueHttpRequest(String url, Map<String,String> params){
client = new HttpClient();
PostMethod post = createPostMethod(url);
for (Map.Entry<String, String> entry : params.entrySet()){
    post.addParameter(entry.getKey(), entry.getValue());
    }

client.executeMethod(post);
String response = post.getResponseBodyAsString();

return response;
}

Here is how I am calling it from FitNesse: 这是我从FitNesse调用的方式:

!|script|CLASS_NAME|
|check|issueHttpRequest;|login|!{username:"guest",password:"guest"}|{"status":"success"}|

When remote debugging in eclipse, params is being passed as empty brackets {}. 在Eclipse中进行远程调试时,参数以空括号{}的形式传递。

Any help would be appreciated. 任何帮助,将不胜感激。 Thanks in advance. 提前致谢。

I noticed that the ! 我注意到了! character before the script table might be a problem. 脚本表之前的字符可能是一个问题。 Try without: 尝试不使用:

|script|CLASS_NAME| |脚本| CLASS_NAME | |check|issueHttpRequest;|login|!{username:"guest",password:"guest"}|{"status":"success"}| !|检查| issueHttpRequest; |登录| {用户名: “客人”,密码为: “客串”} | { “地位”: “成功”} |

Check SLIM MarkupHashTable DataType for reference. 检查SLIM MarkupHashTable数据类型以供参考。

I only tried map arguments do work for SLIM tests in script tables. 我只尝试了映射参数对脚本表中的SLIM测试有效。 So make sure you have this defined before your test if my proposed still workaround does work: 因此,如果我建议的解决方法仍然有效,请确保在测试之前已定义此定义:

!define TEST_SYSTEM {slim} !define TEST_SYSTEM {slim}

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

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