This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 216334
Collapse All | Expand All

(-)a/junit/src/org/netbeans/modules/junit/output/JumpAction.java (-1 / +6 lines)
Lines 79-85 Link Here
79
        } else if (node instanceof CallstackFrameNode){
79
        } else if (node instanceof CallstackFrameNode){
80
            OutputUtils.openCallstackFrame(node, callstackFrameInfo);
80
            OutputUtils.openCallstackFrame(node, callstackFrameInfo);
81
        } else if (node instanceof JUnitTestMethodNode){
81
        } else if (node instanceof JUnitTestMethodNode){
82
            OutputUtils.openTestMethod((JUnitTestMethodNode)node);
82
            if (((JUnitTestMethodNode) node).getTestcase().getTrouble() != null) {
83
                // method failed, find failing line within the testMethod using the stacktrace
84
                OutputUtils.openCallstackFrame(node, "");
85
            } else {
86
                OutputUtils.openTestMethod((JUnitTestMethodNode) node);
87
            }
83
        }
88
        }
84
    }
89
    }
85
90
(-)a/junit/src/org/netbeans/modules/junit/output/OutputUtils.java (-12 / +24 lines)
Lines 155-173 Link Here
155
    }
155
    }
156
156
157
    static void openCallstackFrame(Node node, String frameInfo) {
157
    static void openCallstackFrame(Node node, String frameInfo) {
158
            JUnitTestMethodNode methodNode = getTestMethodNode(node);
158
        // #213935 - copied from org.netbeans.modules.maven.junit.nodes.OutputUtils
159
            FileLocator locator =  methodNode.getTestcase().getSession().getFileLocator();
159
        JUnitTestMethodNode methodNode = getTestMethodNode(node);
160
            if (locator == null){
160
        FileLocator locator = methodNode.getTestcase().getSession().getFileLocator();
161
                return;
161
        if (locator == null) {
162
            return;
163
        }
164
        FileObject testfo = methodNode.getTestcase().getClassFileObject();
165
        final int[] lineNumStorage = new int[1];
166
        FileObject file = getFile(frameInfo, lineNumStorage, locator);
167
        //lineNumStorage -1 means no regexp for stacktrace was matched.
168
        if ((file == null) && (methodNode.getTestcase().getTrouble() != null) && lineNumStorage[0] == -1) {
169
            //213935 we could not recognize the stack trace line and map it to known file
170
            //if it's a failure text, grab the testcase's own line from the stack.
171
            String[] st = methodNode.getTestcase().getTrouble().getStackTrace();
172
            if ((st != null) && (st.length > 0)) {
173
                int index = st.length - 1;
174
                //213935 we need to find the testcase linenumber to jump to.
175
                // and ignore the infrastructure stack lines in the process
176
                while (!testfo.equals(file) && index != -1) {
177
                    file = getFile(st[index], lineNumStorage, locator);
178
                    index = index - 1;
179
                }
162
            }
180
            }
163
            final int[] lineNumStorage = new int[1];
181
        }
164
            FileObject file = getFile(frameInfo, lineNumStorage, locator);
182
        Utils.openFile(file, lineNumStorage[0]);
165
            if ((file == null) && (methodNode.getTestcase().getTrouble() != null)){
166
                String[] st = methodNode.getTestcase().getTrouble().getStackTrace();
167
                if ((st != null) && (st.length > 0))
168
                file = getFile(st[st.length - 1], lineNumStorage, locator);
169
            }
170
            Utils.openFile(file, lineNumStorage[0]);
171
    }
183
    }
172
184
173
    /**
185
    /**
(-)a/maven.junit/src/org/netbeans/modules/maven/junit/nodes/JumpAction.java (-1 / +6 lines)
Lines 80-86 Link Here
80
        } else if (node instanceof JUnitCallstackFrameNode){
80
        } else if (node instanceof JUnitCallstackFrameNode){
81
            OutputUtils.openCallstackFrame(node, callstackFrameInfo);
81
            OutputUtils.openCallstackFrame(node, callstackFrameInfo);
82
        } else if (node instanceof JUnitTestMethodNode){
82
        } else if (node instanceof JUnitTestMethodNode){
83
            OutputUtils.openTestMethod((JUnitTestMethodNode)node);
83
            if (((JUnitTestMethodNode) node).getTestcase().getTrouble() != null) {
84
                // method failed, find failing line within the testMethod using the stacktrace
85
                OutputUtils.openCallstackFrame(node, "");
86
            } else {
87
                OutputUtils.openTestMethod((JUnitTestMethodNode) node);
88
            }
84
        }
89
        }
85
    }
90
    }
86
91
(-)a/testng/src/org/netbeans/modules/testng/output/JumpAction.java (-1 / +6 lines)
Lines 76-82 Link Here
76
        } else if (node instanceof CallstackFrameNode){
76
        } else if (node instanceof CallstackFrameNode){
77
            OutputUtils.openCallstackFrame(node, callstackFrameInfo);
77
            OutputUtils.openCallstackFrame(node, callstackFrameInfo);
78
        } else if (node instanceof TestNGMethodNode){
78
        } else if (node instanceof TestNGMethodNode){
79
            OutputUtils.openTestMethod((TestNGMethodNode)node);
79
            if (((TestNGMethodNode) node).getTestcase().getTrouble() != null) {
80
                // method failed, find failing line within the testMethod using the stacktrace
81
                OutputUtils.openCallstackFrame(node, "");
82
            } else {
83
                OutputUtils.openTestMethod((TestNGMethodNode) node);
84
            }
80
        }
85
        }
81
    }
86
    }
82
87

Return to bug 216334