Home | History | Annotate | Download | only in base
      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.mockito.exceptions.base;
      7 
      8 import org.junit.Test;
      9 import org.mockitoutil.TestBase;
     10 
     11 import static org.junit.Assert.assertEquals;
     12 import static org.junit.Assert.fail;
     13 
     14 public class MockitoAssertionErrorTest extends TestBase {
     15 
     16     private void throwIt() {
     17         throw new MockitoAssertionError("boom");
     18     }
     19 
     20     @Test
     21     public void shouldKeepUnfilteredStackTrace() {
     22         try {
     23             throwIt();
     24             fail();
     25         } catch (MockitoAssertionError e) {
     26             assertEquals("throwIt", e.getUnfilteredStackTrace()[0].getMethodName());
     27         }
     28     }
     29 
     30     @Test
     31     public void should_prepend_message_to_original() {
     32         MockitoAssertionError original = new MockitoAssertionError("original message");
     33         MockitoAssertionError errorWithPrependedMessage = new MockitoAssertionError(original, "new message");
     34         assertEquals("new message\noriginal message", errorWithPrependedMessage.getMessage());
     35     }
     36 }
     37