mockit.Tested Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmockit Show documentation
Show all versions of jmockit Show documentation
JMockit is a Java toolkit for developer (unit/integration) testing.
It contains mocking APIs and other tools, supporting both JUnit and TestNG.
The mocking APIs allow all kinds of Java code, without testability restrictions, to be tested
in isolation from selected dependencies.
/*
* Copyright (c) 2006-2012 Rogério Liesenfeld
* This file is subject to the terms of the MIT license (see LICENSE.txt).
*/
package mockit;
import java.lang.annotation.*;
/**
* Indicates a class to be tested in isolation from selected dependencies, with optional automatic instantiation and/or
* automatic injection of dependencies.
* This annotation is only applicable to instance fields of a test class.
*
* If the tested field is not {@code final} and its value remains {@code null} at the time a test method is about to be
* executed, then a suitable instance of the tested class is created and assigned to the field.
* The instantiation will only be attempted if the tested class has at least one constructor with the same accessibility
* as the class: i.e. either a public constructor in a public class, or a non-private constructor in a
* non-public class.
* Constructor injection will take place, provided all of the constructor parameters (if any) can be satisfied with the
* values of available {@linkplain Injectable injectable} fields and/or injectable test method parameters.
* If the tested class has more than one satisfiable constructor, the one with most parameters is chosen.
* The matching between injectable fields/parameters and constructor parameters is done by
* type when there is only one parameter of a given type; otherwise, by type and name.
*
* Whenever the tested object is created automatically, field injection is also performed.
* Only non-final
instance fields which remain uninitialized at this time are considered, between those
* declared in the tested class itself or in one of its super-classes.
* For each such target field, the value of an still unused {@linkplain Injectable injectable} field or test
* method parameter of the same type is assigned.
* Multiple target fields of the same type can be injected from separate injectables, provided each target field has the
* same name as an available injectable field/parameter of that type.
* Finally, if there is no matching and available injectable value for a given target field, it is left unassigned.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Tested
{
}