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 static java.lang.annotation.ElementType.FIELD;
8   import static java.lang.annotation.ElementType.PARAMETER;
9   import static java.lang.annotation.RetentionPolicy.RUNTIME;
10  
11  import java.lang.annotation.Retention;
12  import java.lang.annotation.Target;
13  
14  /**
15   * Indicates a mock field or a mock parameter for which all classes extending/implementing the {@linkplain Mocked
16   * mocked} type will <em>also</em> get mocked.
17   * <p>
18   * <em>Future</em> instances of a capturing mocked type (ie, instances created sometime later during the test) will
19   * become associated with the mock field/parameter. When recording or verifying expectations on the mock
20   * field/parameter, these associated instances are regarded as equivalent to the original mocked instance created for
21   * the mock field/parameter.
22   *
23   * @see <a href="http://jmockit.github.io/tutorial/Mocking.html#capturing" target="tutorial">Tutorial</a>
24   */
25  @Retention(RUNTIME)
26  @Target({ FIELD, PARAMETER })
27  public @interface Capturing {
28  
29      /**
30       * Max instances.
31       *
32       * @return the int
33       */
34      int maxInstances() default Integer.MAX_VALUE;
35  
36  }