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

mockit.Delegate Maven / Gradle / Ivy

Go to download

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.

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

/**
 * An empty interface to be used with the {@link Expectations#result} field, allowing test code to define invocation
 * results (return values or thrown exceptions) based on test-specific logic.
 * 

* An implementation of this interface should define a method matching the signature of the recorded method/constructor * call. * That is, they should have the same name and parameters. In the case of delegating a constructor, a delegate * method should still be used, with name "$init". *

* Alternatively, for the common case where the delegate implementation class defines a single method, the name * is allowed to be different from the recorded method. * The parameters should still match, though. Besides giving more flexibility, this ability also prevents the test from * breaking in case the recorded method is renamed. * Note that if the delegate class defines two or more methods ({@code private} ones included, if any), then exactly one * of them must match both the name and the parameters of the recorded method. *

* At replay time, when that method/constructor is called the corresponding "delegate" method will be called to produce * the desired result. The arguments passed to the delegate method will be the same as those received by the recorded * invocation during replay. The result can be any return value compatible with the recorded method's return type, or a * thrown error/exception. *

* Even {@code static} methods in the mocked type can have delegates, which in turn can be static or not. * The same is true for {@code private}, {@code final}, and {@code native} methods. *

* In the Tutorial *

* Sample tests: * DocumentManager_JMockit_Test */ public interface Delegate { }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy