Browse souce code repository at: https://github.com/jjYBdx4IL/java-evaluation/blob/master/src/test/java/tests/java/lang/StacktraceTest.java
/*
 * #%L
 * Evaluation
 * %%
 * Copyright (C) 2016 Github jjYBdx4IL Projects
 * %%
 * #L%
 */
package tests.java.lang;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.Test;

/**
 *
 * @author Github jjYBdx4IL Projects
 */
public class StacktraceTest {

    public class One {

        public void overridden() {
        }
    }

    public class Two extends One {

        @Override
        public void overridden() {
            throw new RuntimeException();
        }
    }

    @Test
    public void testSubTypeDisplay() {
        try {
            new Two().overridden();
            fail();
        } catch (Exception ex) {
            assertTrue(ex.getStackTrace()[0].getClassName().endsWith("Two"));
            assertEquals(Two.class.getName(), ex.getStackTrace()[0].getClassName());
        }
    }
    
    @Test
    public void testThreadGetStackTrace() {
        StackTraceElement ste = Thread.currentThread().getStackTrace()[1];
        assertEquals(StacktraceTest.class.getName(), ste.getClassName());
        assertEquals("testThreadGetStackTrace", ste.getMethodName());
    }
}
-------------------------------------------------------------------------------
Test set: tests.java.lang.StacktraceTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in tests.java.lang.StacktraceTest
testSubTypeDisplay  Time elapsed: 0 s
testThreadGetStackTrace  Time elapsed: 0.001 s