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

org.mockito.stubbing.Stubbing Maven / Gradle / Ivy

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

import org.mockito.MockingDetails;
import org.mockito.invocation.Invocation;

/**
 * Stubbing declared on the mock object.
 * See detailed description including sample code and use cases see javadoc for {@link MockingDetails#getStubbings()}.
 *
 * @since 2.2.3
 */
public interface Stubbing {

    /**
     * Returns the method invocation that is stubbed.
     * E.g. in the example stubbing when(mock.foo()).thenReturn(true)
     * the invocation is mock.foo().
     * 

* The invocation instance is mutable. * It is not recommended to modify the state of invocation because it will influence mock behavior. *

* To understand how this method is useful, see the description at {@link MockingDetails#getStubbings()}. * * @since 2.2.3 */ Invocation getInvocation(); /** * Informs if the stubbing was used *

* What does it mean 'used stubbing'? * Stubbing like when(mock.foo()).thenReturn(true) is considered used * when the method mock.foo() is actually invoked during the execution of code under test. *

* This method is used internally by Mockito to report and detect unused stubbings. * Unused stubbings are dead code and should be deleted to increase clarity of tests (see {@link org.mockito.quality.MockitoHint}. *

* To understand how this method is useful, see the description at {@link MockingDetails#getStubbings()}. * * @since 2.2.3 */ boolean wasUsed(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy