我正试图使用可重用特性文件中的一个简单js函数将数组转换为字符串。当我试图在控制台上运行相同的函数时,我看不出有任何原因可以解释为什么数组没有被转换为字符串——它可以毫无问题地工作。有人能提出解决这个问题的方法吗?
"""
* def formatter = function(str){
var formatstring = str.toString();
return formatstring
}
"""
feature file
* def format = call read('../common/resuable.feature)
* def result = format.formatter(value)
* print result
Input = ["ID3:Jigglypuff(NORMAL)"]
Actual result = ["ID3:Jigglypuff(NORMAL)"]
Expected result = ID3:Jigglypuff(NORMAL)
[![When tried same on console][1]][1]
[1]: https://i.stack.imgur.com/tAcIz.png
对不起,如果你打印一个数组,它会有方括号等等,就是这样。
如果您想要纯字符串/内容,请解压缩数组:
* def input = ["ID3:Jigglypuff(NORMAL)"]
* def expected = input[0]