如何在scala测试中将模拟调用与通配符匹配?

时间:2017-05-31 10:26:20

标签: scala testing mockito

寻找类似的东西:

    //Mockito when rawData.filter(filter) thenReturn mockInfo
    //this won't work because the parameter can only match one instance
    //but I want
    Mockito when rawDataRDD.filter(*) thenReturn mockInfo

那么如何在Scala测试中将spied调用与wildcard匹配?

更多解释:

我正在寻找scala test中的间谍模拟,其中将捕获所有调用RDD过滤器并返回指定的模拟结果。

更一般地说,在Scala中寻找匹配函数(就像java中的AnyString),像anyFunction一样匹配所有过滤函数。

1 个答案:

答案 0 :(得分:1)

使用Matchers.any()

 Mockito when rawDataRDD.filter(Matchers.any()) thenReturn mockInfo