Fitnesse 验收测试工具:如何告诉 fitnesse 不要遗漏 space 个字符
Fitnesse Acceptance test tool : how to tell fitnesse to not omit the space characters
我正在用 kotlin 语言编写测试装置,如您所知,class 名称中可以包含 space 个字符,甚至函数名称中也可以使用反引号
我正在使用波斯语编写表格,当 Fitneese 试图找到 class 或函数时,它只是删除所有 space 并在中查找 target.so为了让 Fitnesse 可以使用 classes 和函数,我必须连接所有的单词,并且在使用波斯语时它只是在 fixture class 中读取废话。
我正在寻找一种方法来告诉 fitnesse ,禁用它的删除 space 机制
我试过在单词之间加下划线,虽然看起来很糟糕但是很管用
据我所知,开箱即用地改变 FitNesse 在这方面的行为是不可能的。
您可以尝试创建自定义 'interaction' class(fitnesse.slim.fixtureInteraction.DefaultInteraction
的子 class)来解析 classes 和 methods/functions 换一种方式。
在 wiki 中,您可以指明应该使用您的自定义交互,而不是套件根页面中的 DefaultInteraction
,!define slim.flags {-i your.package.YourOwnInteraction}
根据@Fried Hoeben 的解决方案,我实现了我自己的默认交互 class,它首先删除 class 方法的所有名称的空格,然后根据即将到来的方法检查它来自 Fitnesse 的名字已经被装饰并且它的空格已经被移除
此解决方案适用于方法,但对于 class 匹配,当您重写 searchPathForClass 时,您必须获取所有已通过 class 加载器加载的 class 并装饰他们的名字又多又慢
所以将它用于方法匹配而不是 class 匹配:
class MyDefaultInteraction: DefaultInteraction() {
override fun findMatchingMethod(methodName: String, instance: Any, vararg args: Any?): Method? {
instance.javaClass.methods.forEach {
if(doMethodMatchWithGivenMethodNameAndArguments(it,methodName,args))
return it
}
return super.findMatchingMethod(methodName, instance, *args)
}
private fun doMethodMatchWithGivenMethodNameAndArguments(method: Method, givenMethodName: String, args: Array<out Any?>)=
(decorateMethodNameToBeMatchCandidate(givenMethodName) == decorateMethodNameToBeMatchCandidate(method.name) && doArgsMatch(method, args))
private fun decorateMethodNameToBeMatchCandidate(name:String) = name.replace(" ", "")
.replace(",", "").toLowerCase()
private fun doArgsMatch(method: Method, args: Array<out Any?>) = method.parameterTypes.size == args.size
}
我正在用 kotlin 语言编写测试装置,如您所知,class 名称中可以包含 space 个字符,甚至函数名称中也可以使用反引号
我正在使用波斯语编写表格,当 Fitneese 试图找到 class 或函数时,它只是删除所有 space 并在中查找 target.so为了让 Fitnesse 可以使用 classes 和函数,我必须连接所有的单词,并且在使用波斯语时它只是在 fixture class 中读取废话。
我正在寻找一种方法来告诉 fitnesse ,禁用它的删除 space 机制
我试过在单词之间加下划线,虽然看起来很糟糕但是很管用
据我所知,开箱即用地改变 FitNesse 在这方面的行为是不可能的。
您可以尝试创建自定义 'interaction' class(fitnesse.slim.fixtureInteraction.DefaultInteraction
的子 class)来解析 classes 和 methods/functions 换一种方式。
在 wiki 中,您可以指明应该使用您的自定义交互,而不是套件根页面中的 DefaultInteraction
,!define slim.flags {-i your.package.YourOwnInteraction}
根据@Fried Hoeben 的解决方案,我实现了我自己的默认交互 class,它首先删除 class 方法的所有名称的空格,然后根据即将到来的方法检查它来自 Fitnesse 的名字已经被装饰并且它的空格已经被移除
此解决方案适用于方法,但对于 class 匹配,当您重写 searchPathForClass 时,您必须获取所有已通过 class 加载器加载的 class 并装饰他们的名字又多又慢
所以将它用于方法匹配而不是 class 匹配:
class MyDefaultInteraction: DefaultInteraction() {
override fun findMatchingMethod(methodName: String, instance: Any, vararg args: Any?): Method? {
instance.javaClass.methods.forEach {
if(doMethodMatchWithGivenMethodNameAndArguments(it,methodName,args))
return it
}
return super.findMatchingMethod(methodName, instance, *args)
}
private fun doMethodMatchWithGivenMethodNameAndArguments(method: Method, givenMethodName: String, args: Array<out Any?>)=
(decorateMethodNameToBeMatchCandidate(givenMethodName) == decorateMethodNameToBeMatchCandidate(method.name) && doArgsMatch(method, args))
private fun decorateMethodNameToBeMatchCandidate(name:String) = name.replace(" ", "")
.replace(",", "").toLowerCase()
private fun doArgsMatch(method: Method, args: Array<out Any?>) = method.parameterTypes.size == args.size
}