[RSS]

Call Hierarchy

Author: Petr Dvorak
Version: 6.5
Introduction: This document serves as a test specification for a "Java Call Hierarchy" feature. "Call Hierarchy" is a view that displays a tree representing hierarchy of callers or "callees" of a particular method (order of the items on the same level in the tree can vary, screenshots are informative only).
Comments: To reduce test specification length, TS is written so that test cases may depend on each other. Therefore, you need to perform steps in order if you are not familiar with how "Call Hierarchy" view works.

Test suite: Call Hierarchy

Setup:
- Start IDE with a fresh userdir. Download and unzip projects CallHierarchy and CallHierarchyDep.
- Turn on line numbers by View>Show Line Numbers from the main menu, just to make work with this test specification more fluent.
- Open a sample project CallHierarchy

  1. Callers hierarchy
    1. Open file Main.java in editor
    2. Right-click the method "CapFirstLetter" on line 29 and invoke Call Hierarchy from popup menu
    3. Note: You can alternatively place a caret on "CapFirstLetter" (like "CapF|irstLetter") and invoke Window>Output>Call Hierarchy from the main menu - we will use popup menu in this test specification, but you may try to vary both methods
    • EXPECTED RESULT:
      - New view with a title Java Call Hierarchy is shown in the bottom of the editor.
      - A tree representing all callers of the method is shown (there is only one caller in this case)
      - Show Hierarchy of Callers toggle button is selected.

      http://wiki.netbeans.org/attach/TS_65_CallHierarchy/testcase1.png

  2. Callers hierarchy - Show lines with method calls
    1. Click the sub-node main(String args)::callhierarchy.Main in the tree
    • EXPECTED RESULT: A line with the method call is shown in the bottom part of the "Java Call Hierarchy" view (it is a single line in this case). The called method is in a boldface on the line.

      http://wiki.netbeans.org/attach/TS_65_CallHierarchy/testcase2.png

  3. "Callees" hierarchy
    1. Click Show Hierarchy of Callees toggle button in the "Java Call Hierarchy" view
    • EXPECTED RESULT:
      - All methods that are invoked within method "CapFirstLetter" are shown in the hierarchy view.
      - Clicking the particular tree item displays lines with a method call in the bottom part of a "Java Call Hierarchy" view.

      http://wiki.netbeans.org/attach/TS_65_CallHierarchy/testcase3.png

  4. Call Hierarchy - Scope for invoking
    1. Right-click the comment on line 28 in main.java and invoke Call Hierarchy
    • EXPECTED RESULT:
      - Call Hierarchy for the right-clicked method (which is a "main" method in this case) is displayed in "Java Call Hierarchy" view.
      - Switching from Callers to Callees using toggle buttons works as expected (no methods calling "main" are displayed when exploring callers, methods called from "main" are displayed in the tree when exploring callees).
  5. Call Hierarchy - Refresh
    1. Right-click the comment on line 28 in main.java and invoke Call Hierarchy
    2. Click "Show Hierarchy of Callees" toggle button to show methods called from the "main" method
    3. Delete the first '/' character from the comment on the line 28 to comment-out a portion of code
    4. Click the Refresh button in "Java Call Hierarchy" view
    5. Add the '/' character back to uncomment a portion of code
    6. Click the Refresh button in "Java Call Hierarchy" view again
    • EXPECTED RESULT: Method "CapFirstLetter" is present in the call hierarchy tree (as a callee) if it is called in the main method (in other words, if it is not commented-out in the code).
  6. Call Hierarchy - Invoking outside method
    1. Right-click anywhere on line 1 and invoke Call Hierarchy
    • EXPECTED RESULT: "Select some method to explore" is written in "Java Call Hierarchy" view.

      http://wiki.netbeans.org/attach/TS_65_CallHierarchy/testcase4.png

  7. Call Hierarchy - Recursive calls
    1. Open NewClassRecursive.java in the editor
    2. Invoke Call Hierarchy from the popup menu above the "fib" method on line 14
    • EXPECTED RESULT: Call Hierarchy for the current method is shown. Tree contains only one sub-node, this sub-node has a little badge suggesting recursive call. Results are the same for callers and callees in this case, there are two lines with usage displayed when you click the caller's/callee's node.

      http://wiki.netbeans.org/attach/TS_65_CallHierarchy/testcase5.png

  8. Call Hierarchy - Go to source (First occurrence)
    1. Open NewClassRecursive.java in the editor
    2. Invoke Call Hierarchy from the popup menu above the "fib" method on line 14
    3. Double-click the only sub-node in the tree (the one with a badge indicating recursive call), or invoke Go to source from the popup menu above this sub-node
    • EXPECTED RESULT: You are navigated to the first call within the method fib.
  9. Call Hierarchy - Go to source (Particular occurrence)
    1. Open NewClassRecursive.java in the editor
    2. Invoke Call Hierarchy from the popup menu above the "fib" method on line 14
    3. Click the only sub-node in the tree (the one with a badge indicating recursive call) in order to display lines with method call in the bottom of "Java Call Hierarchy" view
    4. Double-click some of the lines with a method call or invoke Go to source from the popup menu
    • EXPECTED RESULT: You are navigated to the particular call you selected.
  10. Call Hierarchy - Expanding nodes
    1. Open NewClassCycle1.java in editor
    2. Invoke Call Hierarchy from the popup menu above the "gFunct" method on line 14 (you can view callers or callees)
    3. Expand all nodes in the tree
    4. Open main.java in the editor
    5. Invoke Call Hierarchy from the popup menu above the "CapFirstLetterOfEachWord" method on line 45
    6. Click Show Hierarchy of Callers to ensure you are viewing callers of "CapFirstLetterOfEachWord" method
    7. Expand all nodes in the tree again
    • EXPECTED RESULT: Sub-nodes can be expanded to show callers of callers (callees of callees, respectively). Cyclic calls do not cause any problems and are marked with the same badge as recursive calls.

      http://wiki.netbeans.org/attach/TS_65_CallHierarchy/testcase6.png

  11. Call Hierarchy - Scope to Search
    1. Open main.java in the editor, if it is not already opened
    2. Invoke Call Hierarchy from the popup menu above the "CapFirstLetterOfEachWord" method on line 45
    3. Click Show Hierarchy of Callers (again, just to ensure you are viewing callers of "CapFirstLetterOfEachWord" method)
    4. Click Scope to Search button in the "Java Call Hierarchy" and choose Current Project from the popup menu
    5. Click Refresh button in the "Java Call Hierarchy" view
    6. Click Scope to Search button again and choose Open Projects
    7. Click Refresh button again
    • EXPECTED RESULT:
      - Call made from callhierarchydep.Main is not present in the results when you press the Refresh button for the first time, as it is not in the current project.
      - Call made from callhierarchydep.Main is again present in the results after you press the Refresh button for the second time
  12. Call Hierarchy - Invoking in Java file
    1. Open file MyClass.java from project CallHierarchyDep (only the file, not the project)
    2. Right-click in the editor and see the popup menu ("Call Hierarchy" is disabled now)
    3. Double-click main(String args)::callhierarchydep sub-node in the call hierarchy tree (should be still there from the previous case)
    4. When "callhierarchydep.Main" is opened, invoke popup menu above "CapFirstLetterOfEachWord" method on line 19 ("Call Hierarchy" is disabled now)
    5. Open project "CallHierarchyDep"
    6. Invoke popup menu above "CapFirstLetterOfEachWord" method on line 19 in callhierarchydep.Main class again
    • EXPECTED RESULT:
      - Popup menu item "Call Hierarchy" is enabled only in case that project is opened - it is not enabled in case that only a file is opened.
      - Popup menu is enabled in a file after a project containing that file is opened in IDE.

Attachments

sampleProjects.zip Info on sampleProjects.zip 33009 bytes
testcase1.png Info on testcase1.png 13123 bytes
testcase2.png Info on testcase2.png 16456 bytes
testcase3.png Info on testcase3.png 29028 bytes
testcase4.png Info on testcase4.png 8616 bytes
testcase5.png Info on testcase5.png 13237 bytes
testcase6.png Info on testcase6.png 23800 bytes