Java Examples for org.mockito.exceptions.misusing.MissingMethodInvocationException

The following java examples will help you to understand the usage of org.mockito.exceptions.misusing.MissingMethodInvocationException. These source code samples are taken from different open source projects.

Example 1
Project: mockito-master  File: Reporter.java View source code
public static MockitoException missingMethodInvocation() {
    return new MissingMethodInvocationException(join("when() requires an argument which has to be 'a method call on a mock'.", "For example:", "    when(mock.getArticles()).thenReturn(articles);", "", "Also, this error might show up because:", "1. you stub either of: final/private/equals()/hashCode() methods.", "   Those methods *cannot* be stubbed/verified.", "   " + MockitoLimitations.NON_PUBLIC_PARENT, "2. inside when() you don't call method on mock but on some other object.", ""));
}
Example 2
Project: powermock-master  File: MockingFrameworkReporterFactoryImpl.java View source code
public void missingMethodInvocation() {
    throw new org.mockito.exceptions.misusing.MissingMethodInvocationException(join("when() requires an argument which has to be 'a method call on a mock'.", "For example:", "    when(mock.getArticles()).thenReturn(articles);", "Or 'a static method call on a prepared class`", "For example:", "    @PrepareForTest( { StaticService.class }) ", "    TestClass{", "       public void testMethod(){", "           PowerMockito.mockStatic(StaticService.class);", "           when(StaticService.say()).thenReturn(expected);", "       }", "    }", "", "Also, this error might show up because:", "1. inside when() you don't call method on mock but on some other object.", "2. inside when() you don't call static method, but class has not been prepared.", ""));
}