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

mockit.Mock Maven / Gradle / Ivy

/*
 * Copyright (c) 2006 JMockit developers
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
 */
package mockit;

import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;

/**
 * Used inside a {@linkplain MockUp fake} class to indicate a fake method whose implementation will temporarily
 * replace the implementation of a matching "real" method.
 * 

* The fake method must have the same name and the same parameters as the matching real method, except for an optional * first parameter of type {@link Invocation}; if this extra parameter is present, the remaining ones must match the * parameters in the real method. * The fake method must also have the same return type as the matching real method. *

* Method modifiers (public, final, static, etc.) between fake and faked methods * don't have to be the same. * It's perfectly fine to have a non-static fake method for a static faked method (or vice-versa), * for example. * Checked exceptions in the throws clause (if any) can also differ between the two matching methods. *

* A fake method can also target a constructor, in which case the previous considerations still apply, * except for the name of the fake method which must be "$init". *

* Another special fake method, "void $clinit()", will target the static * initializers of the faked class, if present in the fake class. *

* Yet another special fake method is "Object $advice(Invocation)", which if defined will * match every method in the target class hierarchy. * * @see Tutorial */ @Retention(RUNTIME) @Target(METHOD) public @interface Mock { }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy