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

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

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

import org.mockito.Mockito;
import org.mockito.NotExtensible;

/**
 * Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style
 * 

* Example: *


 *   doThrow(new RuntimeException()).when(mockedList).clear();
 *
 *   //following throws RuntimeException:
 *   mockedList.clear();
 * 
* * Also useful when stubbing consecutive calls: * *

 *   doThrow(new RuntimeException("one")).
 *   doThrow(new RuntimeException("two"))
 *   .when(mock).someVoidMethod();
 * 
* * Read more about those methods: *

* {@link Mockito#doThrow(Throwable[])} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ @SuppressWarnings("unchecked") @NotExtensible public interface Stubber extends BaseStubber { /** * Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style *

* Example: *


     *   doThrow(new RuntimeException())
     *   .when(mockedList).clear();
     *
     *   //following throws RuntimeException:
     *   mockedList.clear();
     * 
* * Read more about those methods: *

* {@link Mockito#doThrow(Throwable[])} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} * * @param mock The mock * @return select method for stubbing */ T when(T mock); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy