Home | History | Annotate | Download | only in bugs
      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 junit.framework.TestCase.fail;
     12 import static org.mockito.Mockito.*;
     13 
     14 public class ActualInvocationHasNullArgumentNPEBugTest extends TestBase {
     15 
     16     public interface Fun {
     17         String doFun(String something);
     18     }
     19 
     20     @Test
     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             fail();
     33         } catch(AssertionError r) {
     34             //it's ok, we just want to reproduce the bug
     35         }
     36     }
     37 }
     38