All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockito.Spy Maven / Gradle / Ivy

There is a newer version: 2.0.2-beta
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package org.mockito;

import java.lang.annotation.*;

/**
 * Allows shorthand wrapping of field instances in an spy object.
 * 
 * 

* Example: * *

 * public class Test{
 *    @Spy Foo spyOnFoo = new Foo();
 *    @Before
 *    public void init(){
 *       MockitoAnnotations.init(this);
 *    }
 *    ...
 * }
 * 
*

* Same as doing: * *

 * Foo spyOnFoo = Mockito.spy(new Foo());
 * 
* * Warning if you call MockitoAnnotations.init(this) in a * super class constructor then this will not work. It is because fields * in subclass are only instantiated after super class constructor has returned. * It's better to use @Before. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @Documented public @interface Spy { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy