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

mockit.Injectable Maven / Gradle / Ivy

Go to download

JMockit is a Java toolkit for automated developer testing. It contains mocking/faking APIs and a code coverage tool, 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.

There is a newer version: 1.49
Show newest version
/*
 * Copyright (c) 2006 Rogério Liesenfeld
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
 */
package mockit;

import java.lang.annotation.*;

/**
 * Indicates that the value of a mock field or mock parameter will be an isolated {@linkplain Mocked mocked} instance,
 * intended to be passed or injected into the code under test.
 * Such instances can be said to be proper mock objects, in contrast to the mocked instances of a regular
 * {@code @Mocked} type.
 * 

* For the duration of each test where the mock field/parameter is in scope, only one injectable instance is * mocked; other instances of the same mocked type are not affected. * For an injectable mocked class, static methods and constructors are not mocked; * only non-native instance methods are. *

* When used in combination with {@linkplain Tested @Tested}, the values of injectable fields and parameters will be * used for automatic injection into the tested object. * Additionally, this annotation can be applied to non-mocked fields of primitive or array types, which will also be * used for injection. * * @see #value * @see Tutorial */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.PARAMETER}) public @interface Injectable { /** * Specifies a literal value when the type of the injectable mock field/parameter is {@code String}, a primitive * type, or an enum type. * For a primitive type, the value provided must be convertible to it. * For an enum type, the given textual value must equal the name of one of the possible enum values. *

* When a value is provided for an injectable whose type is {@code String} or an enum type, said type is not * mocked; otherwise, it is. */ String value() default ""; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy