diff --git a/junit/src/org/netbeans/modules/junit/output/JUnitTestMethodNode.java b/junit/src/org/netbeans/modules/junit/output/JUnitTestMethodNode.java --- a/junit/src/org/netbeans/modules/junit/output/JUnitTestMethodNode.java +++ b/junit/src/org/netbeans/modules/junit/output/JUnitTestMethodNode.java @@ -38,6 +38,7 @@ * Contributor(s): * * Portions Copyrighted 2009 Sun Microsystems, Inc. + * markiewb@netbeans.org */ package org.netbeans.modules.junit.output; @@ -113,11 +114,32 @@ @Override public Action getPreferredAction() { - return new JumpAction(this, null); + // try to create a jump action to the cause of the test failure + Action actionForStackFrame = createJumpActionForStackFrameOfFailingTestMethod(); + if (null != actionForStackFrame) { + return actionForStackFrame; + } + + return createJumpActionToMethod(); + } + + protected Action createJumpActionForStackFrameOfFailingTestMethod() { + if (testcase.getTrouble() != null) { + String[] st = testcase.getTrouble().getStackTrace(); + if ((st != null) && (st.length > 0)) { + String stacktraceLine = st[st.length - 1]; + return new JumpAction(this, stacktraceLine); + } + } + return null; } public JUnitTestcase getTestcase(){ return (JUnitTestcase)testcase; } + protected Action createJumpActionToMethod() { + return new JumpAction(this, null); + } + } diff --git a/junit/src/org/netbeans/modules/junit/output/JumpAction.java b/junit/src/org/netbeans/modules/junit/output/JumpAction.java --- a/junit/src/org/netbeans/modules/junit/output/JumpAction.java +++ b/junit/src/org/netbeans/modules/junit/output/JumpAction.java @@ -29,6 +29,8 @@ * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. + * + * markiewb@netbeans.org * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding @@ -78,8 +80,13 @@ OutputUtils.openTestsuite((TestsuiteNode)node); } else if (node instanceof CallstackFrameNode){ OutputUtils.openCallstackFrame(node, callstackFrameInfo); - } else if (node instanceof JUnitTestMethodNode){ - OutputUtils.openTestMethod((JUnitTestMethodNode)node); + } else if (node instanceof JUnitTestMethodNode) { + if (null != callstackFrameInfo) { + // try to open stackFrame if available + OutputUtils.openCallstackFrame(node, callstackFrameInfo); + } else { + OutputUtils.openTestMethod((JUnitTestMethodNode) node); + } } }