Search in sources :

Example 1 with InjectMocks

use of org.mockito.InjectMocks in project mockito by mockito.

the class InjectMocksScanner method scan.

/**
     * Scan fields annotated by @InjectMocks
     *
     * @return Fields that depends on Mock
     */
@SuppressWarnings("unchecked")
private Set<Field> scan() {
    Set<Field> mockDependentFields = new HashSet<Field>();
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        if (null != field.getAnnotation(InjectMocks.class)) {
            assertNoAnnotations(field, Mock.class, Captor.class);
            mockDependentFields.add(field);
        }
    }
    return mockDependentFields;
}
Also used : Field(java.lang.reflect.Field) InjectMocks(org.mockito.InjectMocks) HashSet(java.util.HashSet)

Aggregations

Field (java.lang.reflect.Field)1 HashSet (java.util.HashSet)1 InjectMocks (org.mockito.InjectMocks)1