修改文件:fitnesse.slim.fixtureInteraction.DefaultInteraction.java

修改如下三处内容:

(注意只支持仅含有一个参数,且该参数是多参数的fixture)

 protected Method findMatchingMethod(String methodName, Class<?> k, int nArgs) {
Method[] methods = k.getMethods();
if(methods == null) {
methods = k.getMethods();
} for (Method method : methods) {
boolean hasMatchingName = method.getName().equals(methodName);
if(hasMatchingName && method.isVarArgs()){
return method;
}
boolean hasMatchingArguments = method.getParameterTypes().length == nArgs;
if (hasMatchingName && hasMatchingArguments) {
return method;
}
}
return null;
}
 protected Object[] convertArgs(Method method, Object[] args) {
Type[] argumentParameterTypes=null;
if(method.isVarArgs()){
return args;
}else{
argumentParameterTypes = method.getGenericParameterTypes();
}
return ConverterSupport.convertArgs(args, argumentParameterTypes);
}
 public Object methodInvoke(Method method, Object instance, Object... convertedArgs) throws Throwable {
try {
if(method.isVarArgs()){
String[] s = new String[convertedArgs.length];
int i =0;
for(Object arg:convertedArgs){
s[i]=arg.toString();
i++;
}
return method.invoke(instance, (Object)s);
}else{
return method.invoke(instance, convertedArgs);
} } catch (InvocationTargetException e) {
if(e.getCause() != null){
throw e.getCause();
}else{
throw e.getTargetException();
}
}
}

使用例子:

给Fitnesse添加调用多参数fixture的调用方法的更多相关文章

  1. setTimeout调用带参数的函数的方法

    function test(s){    alert(s);}window.setTimeout(function(){test('str');},1000);这样就可以了...为什么是这样呢.因为s ...

  2. pytest动态添加命令行参数并获取(钩子函数:pytest_addoption)

    考虑场景: 我们的自动化用例需要支持在不同测试环境运行,有时候在dev环境运行,有时候在test环境运行: 有时候需要根据某个参数不同的参数值,执行不同的业务逻辑: 上面的场景我们都可以通过" ...

  3. addEventListener调用带参数函数

    当传递参数值时,使用"匿名函数"调用带参数的函数: <body> <button id="btn">click me</butto ...

  4. Java程序调用带参数的shell脚本返回值

    Java程序调用带参数的shell脚本返回值 首先来看看linux中shell变量(\(#,\)@,$0,$1,\(2)的含义解释 变量说明: -  \)$  Shell本身的PID(ProcessI ...

  5. handlerAdapter与方法调用(参数的解析)

    前提:当找到handler以后,那么就要让handler发挥作用,这个时候handlerAdapter就派上用场了 这里面比较复杂就是requestMappingHandlerAdapter了,其他的 ...

  6. WebApi接口安全性 接口权限调用、参数防篡改防止恶意调用

    背景介绍 最近使用WebApi开发一套对外接口,主要是数据的外送以及结果回传,接口没什么难度,采用WebApi+EF的架构简单创建一个模板工程,使用template生成一套WebApi接口,去掉put ...

  7. 多线程调用有参数的方法---c# Thread 与 Task

    C#实现多线程的方式:Task——任务   简介 .NET 4包含新名称空间System.Threading.Tasks,它 包含的类抽象出了线程功能. 在后台使用ThreadPool. 任务表示应完 ...

  8. Python趣味入门9:函数是你走过的套路,详解函数、调用、参数及返回值

    1.概念 琼恩·雪诺当上守夜人的司令后,为训练士兵对付僵尸兵团,把成功斩杀僵尸的一系列动作编排成了"葵花宝典剑法",这就是函数.相似,在计算机世界,一系列前后连续的计算机语句组合在 ...

  9. 给定时器settimeout、setInterval调用传递参数

    无论是window.setTimeout还是window.setInterval,在使用函数名作为调用句柄时都不能带参数,而在 许多场合必须要带参数,这就需要想方法解决.例如对于函数hello(_na ...

随机推荐

  1. java中byte转string的方法有哪些?

    1.第一种 byte b = 1; String valueOf = String.valueOf(b) 2.第二种 byte b = 1; String st = Byte.toString(b); ...

  2. Java中Iterator的fast-fail分析

    1.fail-fast简介 fail-fast机制是java集合(Collection)中的一个错误机制.当多个线程对同一个集合的内容进行操作时,就可能会产生fail-fast事件. 例如:当某一个线 ...

  3. Java for LeetCode 080 Remove Duplicates from Sorted Array II

    Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For examp ...

  4. perl之创建临时文件夹遇到同名文件该咋办

    当你在目录下进行一系列操作时,若要创建许多文件或者修改文件,可能会遇到许多麻烦的事.所以呢,新建一个文件夹,然后在这个文件夹下新建文件或者修改文件.假设,你的代码要在一个目录下新建一个文件夹,名为Tm ...

  5. poj 1146 ID Codes (字符串处理 生成排列组合 生成当前串的下一个字典序排列 【*模板】 )

    ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6229   Accepted: 3737 Descript ...

  6. Smack编程库进行代码功能调试

    http://www.tuicool.com/articles/U3Afiy 使用Smack编程库进行代码功能调试 关于Smack编程库,前面我们提到,它是面向Java端的api,主要在PC上使用,利 ...

  7. hdu 6121 Build a tree

    /** * 题意:一棵 n 个点的完全 k 叉树,结点标号从 0 到 n - 1,求以每一棵子树的大小的异或和. * 解法:k叉树,当k=1时,特判,用xorn函数,具体解释:http://blog. ...

  8. intent实现Activity之间跳转的各种传值

    一.在Activity之间传递String类型的数据 传递 @Override public void onClick(View v) { String num1 = firstNum.getText ...

  9. 机器学习: Logistic Regression--python

    今天介绍 logistic regression,虽然里面有 regression 这个词,但是这其实是一种分类的方法,这个分类方法输出的也是 0-1 之间的一个数,可以看成是一种概率输出,这个分类器 ...

  10. 51nod_1236_序列求和 V3 _组合数学

    51nod_1236_序列求和 V3 _组合数学 Fib(n)表示斐波那契数列的第n项,Fib(n) = Fib(n-1) + Fib(n-2).Fib(0) = 0, Fib(1) = 1. (1, ...