相关疑难解决方法(0)

如何编写一个不等于某事的匹配器

我正在尝试为通话创建一个模拟器.说我有这个方法我试图存根:

class ClassA {
  public String getString(String a) {
    return a + "hey";
  }
}
Run Code Online (Sandbox Code Playgroud)

我想嘲笑的是:第一个例子是

when(classA.getString(eq("a")).thenReturn(...);`
Run Code Online (Sandbox Code Playgroud)

在同一测试案例中

when(classA.getString([anything that is not a])).thenReturn(somethingelse);
Run Code Online (Sandbox Code Playgroud)

第二个案例是我的问题:我如何匹配anyString()"a"以外的其他?

java junit matcher mockito

45
推荐指数
3
解决办法
2万
查看次数

标签 统计

java ×1

junit ×1

matcher ×1

mockito ×1