1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockito; 6 7 import java.lang.annotation.Documented; 8 import java.lang.annotation.ElementType; 9 import java.lang.annotation.Retention; 10 import java.lang.annotation.RetentionPolicy; 11 import java.lang.annotation.Target; 12 13 /** 14 * Allows shorthand {@link org.mockito.ArgumentCaptor} creation on fields. 15 * 16 * <p>Example: 17 * <pre class="code"><code class="java"> 18 * public class Test{ 19 * 20 * @Captor ArgumentCaptor<AsyncCallback<Foo>> captor; 21 * 22 * private AutoCloseable closeable; 23 * 24 * @Before 25 * public void open() { 26 * closeable = MockitoAnnotations.openMocks(this); 27 * } 28 * 29 * @After 30 * public void release() throws Exception { 31 * closeable.close(); 32 * } 33 * 34 * @Test public void shouldDoSomethingUseful() { 35 * //... 36 * verify(mock).doStuff(captor.capture()); 37 * assertEquals("foo", captor.getValue()); 38 * } 39 * } 40 * </code></pre> 41 * 42 * <p> 43 * One of the advantages of using @Captor annotation is that you can avoid warnings related capturing complex generic types. 44 * 45 * @see ArgumentCaptor 46 * @since 1.8.3 47 */ 48 @Retention(RetentionPolicy.RUNTIME) 49 @Target(ElementType.FIELD) 50 @Documented 51 public @interface Captor {} 52