コード例 #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 importMockInReusableVerificationBlock() {
    new ReusableExpectations() {};

    dependency.notifyBeforeSave();
    dependency.save();

    new ReusableVerifications() {};
  }
コード例 #3
0
  @Test
  public void importMockFromReusableExpectationBlock() {
    new ReusableExpectations() {};

    dependency.notifyBeforeSave();
    dependency.save();

    new VerificationsInOrder() {
      Dependency dep;

      {
        dep.notifyBeforeSave();
        unverifiedInvocations();
      }
    };
  }
コード例 #4
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) {};
  }
コード例 #5
0
 {
   mock.save();
   maxTimes = 1;
 }
コード例 #6
0
 private void exerciseCodeUnderTest() {
   mock.prepare();
   mock.setSomething(123);
   mock.editABunchMoreStuff();
   mock.save();
 }