• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 
6 package org.mockitousage.bugs;
7 
8 import org.junit.Test;
9 import org.mockitoutil.TestBase;
10 
11 import static org.junit.Assert.fail;
12 import static org.mockito.Mockito.*;
13 
14 public class ActualInvocationHasNullArgumentNPEBugTest extends TestBase {
15 
16     public interface Fun {
doFun(String something)17         String doFun(String something);
18     }
19 
20     @Test
shouldAllowPassingNullArgument()21     public void shouldAllowPassingNullArgument() {
22         //given
23         Fun mockFun = mock(Fun.class);
24         when(mockFun.doFun((String) anyObject())).thenReturn("value");
25 
26         //when
27         mockFun.doFun(null);
28 
29         //then
30         try {
31             verify(mockFun).doFun("hello");
32         } catch(AssertionError r) {
33             //it's ok, we just want to reproduce the bug
34             return;
35         }
36         fail();
37     }
38 }
39