Home | History | Annotate | Download | only in mockref
      1 /*
      2  * Copyright (c) 2007 Mockito contributors
      3  * This program is made available under the terms of the MIT License.
      4  */
      5 package org.mockito.internal.invocation.mockref;
      6 
      7 import org.assertj.core.api.Assertions;
      8 import org.junit.Test;
      9 import org.mockito.internal.invocation.mockref.MockWeakReference;
     10 import org.mockitoutil.TestBase;
     11 
     12 import static org.junit.Assert.fail;
     13 
     14 public class MockWeakReferenceTest extends TestBase {
     15 
     16     @Test
     17     public void descriptive_exception_when_mock_was_collected() {
     18         try {
     19             //when
     20             new MockWeakReference(null).get();
     21             //then
     22             fail();
     23         } catch (Exception e) {
     24             Assertions.assertThat(e).hasMessageContaining("The mock object was garbage collected");
     25         }
     26     }
     27 }
     28