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.", " " + NON_PUBLIC_PARENT, "2. inside when() you don't call method on mock but on some other object.", "" )); }
public void missingMethodInvocation() { throw 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.", "2. inside when() you don't call method on mock but on some other object.", "3. the parent of the mocked class is not public.", " It is a limitation of the mock engine.", "" )); }
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.", "" )); }
public void missingMethodInvocation() { throw 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.", "2. inside when() you don't call method on mock but on some other object.", "" )); }