View Javadoc
1   /*
2    * Copyright (c) 2006 JMockit developers
3    * This file is subject to the terms of the MIT license (see LICENSE.txt).
4    */
5   package mockit;
6   
7   import edu.umd.cs.findbugs.annotations.NonNull;
8   
9   /**
10   * Same as {@link Verifications}, but checking that <em>all</em> invocations from code under test are explicitly
11   * verified, except for those already verified through other means.
12   *
13   * <pre>{@code
14   * // Exercise tested code.
15   * codeUnderTest.doSomething();
16   *
17   * // Now verify that expected invocations occurred in any order, with no invocations left unverified.
18   * new FullVerifications() {{
19   *    <strong>mock1</strong>.expectedMethod(anyInt);
20   *    <strong>mock2</strong>.anotherExpectedMethod(1, "test"); times = 2;
21   * }};
22   * }</pre>
23   *
24   * Any invocation from code under test that is not covered by an explicit verification, or by an invocation count
25   * constraint when recorded, will cause an assertion error to be thrown.
26   *
27   * @see #FullVerifications()
28   * @see #FullVerifications(Object...)
29   * @see <a href="http://jmockit.github.io/tutorial/Mocking.html#fullVerification" target="tutorial">Tutorial</a>
30   */
31  public class FullVerifications extends Verifications {
32      /**
33       * Begins <em>full</em> verification on the mocked types/instances that can potentially be invoked from code under
34       * test.
35       *
36       * @see #FullVerifications(Object...)
37       */
38      protected FullVerifications() {
39          super(false);
40      }
41  
42      /**
43       * Same as {@link #FullVerifications()}, but restricting the verification to the specified mocked types and/or
44       * mocked instances.
45       *
46       * @param mockedTypesAndInstancesToVerify
47       *            one or more of the mocked types (ie, <code>Class</code> objects) and/or mocked instances that are in
48       *            scope for the test; for a given mocked <em>instance</em>, all classes up to (but not including)
49       *            <code>java.lang.Object</code> are considered
50       */
51      protected FullVerifications(@NonNull Object... mockedTypesAndInstancesToVerify) {
52          super(false, mockedTypesAndInstancesToVerify);
53      }
54  }