【问题标题】:What does the with() method of jMock do?jMock 的 with() 方法有什么作用?
【发布时间】:2013-05-30 05:39:28
【问题描述】:

我看到 with() 方法在测试驱动开发中与 assertThat() 方法一起使用,但我不明白 with() 的作用。有人可以用一个清晰​​的例子来解释。我似乎找不到任何东西。

谢谢。

【问题讨论】:

    标签: java tdd jmock


    【解决方案1】:

    它允许您指定一组可接受的输入。我认为它的目的是像英语一样阅读,例如“使用任何整数调用 add”。

    这是来自下面链接的备忘单的示例:

    allowing (calculator).add(with(any(int.class)), with(any(int.class)));
    

    http://jmock.org/cheat-sheet.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-21
      • 1970-01-01
      • 2023-03-18
      • 2016-04-25
      • 1970-01-01
      • 1970-01-01
      • 2015-04-07
      相关资源
      最近更新 更多