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