コード例 #1
0
  @Test
  public void verifyAllInvocationsToOneOfTwoMocksInIteratingBlock(AnotherDependency mock2) {
    mock2.doSomething();
    mock.setSomething(123);
    mock.save();
    mock2.doSomethingElse(1);
    mock.setSomething(45);
    mock.save();
    mock2.doSomethingElse(2);

    new FullVerifications(2, mock) {
      {
        mock.setSomething(anyInt);
        mock.save();
      }
    };
  }
コード例 #2
0
  @Test
  public void verifyNoInvocationsOnOneOfTwoMockedDependenciesBeyondThoseRecordedAsExpected(
      final AnotherDependency mock2) {
    new NonStrictExpectations() {
      {
        mock.setSomething(anyInt);
        minTimes = 1;
        mock2.doSomething();
        times = 1;
      }
    };

    mock.prepare();
    mock.setSomething(1);
    mock.setSomething(2);
    mock.save();
    mock2.doSomething();

    new FullVerifications(mock2) {};
  }
コード例 #3
0
 private void exerciseCodeUnderTest() {
   mock.prepare();
   mock.setSomething(123);
   mock.editABunchMoreStuff();
   mock.save();
 }