TS 7 Refactoring

Revision as of 14:21, 17 May 2012 by Ttokoly (Talk | contribs)

Refactoring Test Specification

Author: Tomáš Tököly
Last update: 21.3.2012
Introduction: This document contains some of usual/typical scenarios that can be encountered by user which want to test a refactoring functionality included in the NetBeans IDE. That means Find Usages, Rename, Move Class, Change Method Parameters, Encapsulate Fields, some miscellaneous tests and some tests from JDK 1.5.
This TS is an updated version of old TS for NetBeans 6.1

  • Note: In every test suite is needed an specific project. Link where you can find it is in begining of each suite. These steps are required in each suite to be possible to go through them.
    • Unzip needed project to some work directory.
    • Start IDE with a clean userdir.
    • Invoke File | Open Project... action.
    • Select unzipped project and press 'Open Project' button.
    • Scanning structure of project should be performed (it takes a while).

Contents


Test suite: Find Usages

Purpose: To verify if this part of refactoring functionality corresponds with design and works right.
Setup: Project default is needed in this test suite.
Note: It does not affect functionality of Find Usages if "Open In New Tab" checkbox is checked or unchecked.

  1. Class - Usages
    1. Select org.netbeans.tests.examples.packa.Bean class in the Projects view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Usages choice, unselect other options and confirm it by the Find button.
    • EXPECTED RESULT: "Usages of class Bean [33 occurrences]"
      should be displayed in the first line of Usages window.
      35 occurrences are found if 'Search in Comments' is checked.
  2. Class - All Subtypes
    1. Select org.netbeans.tests.examples.packa.Bean class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find All Subtypes choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find All SubTypes of class Bean [8 occurrences]"
      should be displayed in the first line of Usages window.
      8 occurrences are found if 'Search in Comments' is checked.
  3. Class - Direct Subtypes
    1. Select org.netbeans.tests.examples.packa.Bean class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Direct Subtypes Only choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find Direct SubTypes of class Bean [2 occurrences]"
      should be displayed in the first line of Usages window.
      2 occurrences are found if 'Search in Comments' is checked.
  4. Interface - Usages
    1. Select org.netbeans.tests.examples.packc.Makable class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Usages choice and confirm it by the Find button.
    • EXPECTED RESULT: "Usages of interface Makable [17 occurrences]"
      should be displayed in the first line of Usages window.
      18 occurrences are found if 'Search in Comments' is checked.
  5. Interface - All Subtypes
    1. Select org.netbeans.tests.examples.packc.Makable class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find All Subtypes choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find All SubTypes of interface Makable [7 occurrences]"
      should be displayed in the first line of Usages window.
      7 occurrences are found if 'Search in Comments' is checked.
  6. Interface - Direct Subtypes
    1. Select org.netbeans.tests.examples.packc.Makable class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Direct Subtypes Only choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find Direct SubTypes of interface Makable [3 occurrences]"
      should be displayed in the first line of Usages window.
      3 occurrences are found if 'Search in Comments' is checked.
  7. Constructor
    1. Put caret on constructor BeanB() in the org.netbeans.tests.examples.packb.BeanB class on 26th line.
    2. Invoke Find Usages action from the popup menu.
    3. Select Find Usages check box in dialog and press Find button.
    • EXPECTED RESULT: "Usages of BeanB [5 occurrences]"
      should be displayed in the first line of Usages window.
      5 occurrences are found if 'Search in Comments' is checked.
  8. Method - Usages
    1. Put caret over make(int, String, Bean) method in the org.netbeans.tests.examples.packc.Makable class on 18th line.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select only Find Usages checkbox and confirm it by Find button.
    • EXPECTED RESULT: "Usages of Makable.make [4 occurrences]"
      should be displayed in the first line of Usages window.
      4 occurrences are found if 'Search in Comments' is checked.
  9. Method - Overriding Methods
    1. Put caret over make(int, String, Bean) in the org.netbeans.tests.examples.packc.Makable class on 18th line.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select only Find Overriding Methods checkbox and confirm it by Find button.
    • EXPECTED RESULT: "Overriding Methods of Makable.make [5 occurrences]"
      should be displayed in the first line of Usages window.
      5 occurrences are found if 'Search in Comments' is checked.
  10. Method - Search from Base Class
    1. Put caret over make(int index, java.lang.String s, org.netbeans.tests.examples.packa.Bean bean) in the org.netbeans.tests.examples.packb.BeanB class on 73th line.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select only Find Usages and Search from Base Class checkboxies and confirm it by Find button.
    • EXPECTED RESULT: "Usages of Makable.make [4 occurrences]"
      should be displayed in the first line of Usages window.
      4 occurrences are found if 'Search in Comments' is checked.
  11. Field
    1. Put caret over refID in the org.netbeans.tests.examples.packa.Bean class on 27th line.
    2. Invoke Find Usages action from the popup menu.
    3. Confirm dialog by Find button.
    • EXPECTED RESULT: "Usages of refID [13 occurrences]"
      should be displayed in the first line of Usages window.
      16 occurrences are found if 'Search in Comments' is checked.
  12. Java Class - String
    1. Open org.netbeans.tests.examples.packc.Makable.
    2. Put caret over String in declaration of method make(...) on 18th line.
    3. Invoke Find Usages action from the popup menu.
    4. Select Find Usages radio button and set Scope to project Current Project (default), confirm it by Find button.
    • EXPECTED RESULT: "Usages of class String [39 occurrences]"
      should be displayed in the first line of Usages window.
      40 occurrences are found if Search in Comments is checked.
  13. Java Class - scope
    1. Open at least one another project.
    2. Open org.netbeans.tests.examples.packc.Makable.
    3. Put caret over String in declaration of method make(...) on 18th line.
    4. Invoke Find Usages action from the popup menu.
    5. Select Find Usages radio button and set Scope to Open Projects, confirm it by Find button.
    • EXPECTED RESULT: Usages of class String are found in all opened projects.


Test suite: Rename

Purpose: To verify if this part of refactoring functionality corresponds with design and works right.
Setup: Project default is needed in this test suite.
Notes & Instructions:

  • Try to clean & build project after each refactoring, there should not be any compilation error, unless it is explicitly written in this test specification.
  • After each testcase use Undo action to get sources to original state or perform opposite refactoring (e.g. rename it back).
  • The number of occurrences can differ, the significant is that the application is compilable and its behavior is not changed.
  1. Package
    1. Select org.netbeans.tests.examples.packa package node in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new package name org.netbeans.tests.examples.packarenamed in the Rename dialog, confirm this dialog by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename org.netbeans.tests.examples.packa to org.netbeans.tests.examples.packarenamed [23 occurrences]
      should be displayed in Refactoring window.
      23 occurrences are updated if 'Apply Rename on Comments' is checked.
  2. Package in Files view
    1. Switch to the Files tab and select default/src/org package node.
    2. Click to the node to activate its inplace rename.
    3. Fill a new package name com and confirm by enter key.
    4. The Rename org dialog should be displayed. Confirm by Preview button.
    5. Press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename org to com [51 occurrences]
      should be displayed in Refactoring window.
      51 occurrences are updated if 'Apply Rename on Comments' is checked.
  3. Class
    1. Select org.netbeans.tests.examples.packa.Bean class node in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new class name BeanRenamed and confirm it by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Rename Bean to BeanRenamed [36 occurrences]
      should be displayed in Refactoring window.
      38 occurrences are updated if 'Apply Rename on Comments' is checked.
  4. Class - non-primary top level
    1. Put caret over name in declaration of org.netbeans.tests.examples.packb.BeansD.BeanD class and invoke Refactor | Rename action from the popup menu.
    2. Fill a new class name BeanDRenamed and confirm it by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename BeanD to BeanDRenamed [4 occurrences]
      should be displayed in Refactoring window.
      4 occurrences are updated if 'Apply Rename on Comments' is checked.
  5. Class - inline
    1. Select org.netbeans.tests.examples.packa.Bean class node in the Project view and click to the node to activate its inplace rename.
    2. Fill a new class name BeanRenamed and confirm by enter key
    3. The rename dialog should be displayed. Confirm the dialog by Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename Bean to BeanRenamed [36 occurrences]
      should be displayed in Refactoring window.
      38 occurrences are updated if 'Apply Rename on Comments' is checked.
  6. Interface
    1. Select org.netbeans.tests.examples.packc.Makable interface node in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new interface name MakableRenamed and confirm this dialog by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename Makable to MakableRenamed [19 occurrences]
      should be displayed in Refactoring window.
      20 occurrences are updated if 'Apply Rename on Comments' is checked.
  7. Rename Method
    1. Put caret over getProtectedProperty() of the org.netbeans.tests.examples.packb.BeanA class and invoke Refactor | Rename action from the popup menu.
    2. There should be displayed two warnings:
      O There are methods in subclasses/implementors of BeanA that override or implement this method. They will also be renamed.
      O The methods in subclasses/implementors of getProtectedProperty() that override or implement this method, also override or implement the method in super classes/interfaces. The sources will not compile after refactoring!
    3. Press Next button.
    4. Fill a new method name getProtectedPropertyRenamed and confirm this dialog.
    5. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename getProtectedProperty to getProtectedPropertyRenamed [14 occurrences]
      should be displayed in Refactoring window.
      14 occurrences are updated if 'Apply Rename on Comments' is checked.
  8. Rename Field
    1. Put caret on field protectedProperty of the org.netbeans.tests.examples.packb.BeanA class in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new field name protectedPropertyRenamed, uncheck checkbox 'Rename Getters and Setters' and confirm this dialog.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename protectedProperty to protectedPropertyRenamed [19 occurrences]
      should be displayed in Refactoring window.
      24 occurrences are updated if 'Apply Rename on Comments' is checked.
  9. Rename Field with Getters and Setters
    1. Put caret on field protectedProperty of the org.netbeans.tests.examples.packb.BeanA class in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new field name protectedPropertyRenamed, check checkbox 'Rename Getters and Setters' and confirm this dialog.
      There should be displayed a warning:
      O There are methods in subclasses/implementors of BeanA that override or implement this method. They will also be renamed.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename protectedProperty to protectedPropertyRenamed [37 occurrences]
      should be displayed in Refactoring window.
      42 occurrences are updated if 'Apply Rename on Comments' is checked.
  10. Rename Local Field
    1. Open class org.netbeans.tests.examples.packc.BeanE in the source editor.
    2. Move cursor to attribute v1 of the method public double count(double[[ | ]] v1, double[[ | ]] v2) and invoke Refactor | Rename action from the popup menu.
    3. Fill a new field name vector1 and and confirm this dialog
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename v1 to vector1 [9 occurrences]
      should be displayed in Refactoring window.
      9 occurrences are updated if 'Apply Rename on Comments' is checked.


Test suite: Move Class

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.
Setup: Project default is needed in this test suite.
Notes & Instructions:

  • After each refactoring is performed, call Undo action to get sources to original state. Check that Undo is performed correctly.
  1. Move class
    1. Select org.netbeans.tests.examples.packa.Bean class in the Project view and invoke Refactor | Move... action from the popup menu.
    2. Select org.netbeans.tests.examples.packb in To Package combobox and confirm it by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Move class Bean to org.netbeans.tests.examples.packb package [15 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project should be compilable.
  2. Package private field
    1. Select org.netbeans.tests.examples.packb.BeanA class in the Project view and invoke Refactor | Move... action from the popup menu
    2. Select org.netbeans.tests.examples.packa in To Package combobox and and confirm it by Preview button.
    3. There should be displayed a warning:
      O Class "BeanB" within the same package is using feature "protectedProperty" of class you want to move("BeanA"). Continue by Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Move class BeanA to org.netbeans.tests.examples.packa package [6 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project will not be compilable because of using of package private field protectedProperty by classes in org.netbeans.tests.examples.packb.
  3. Default package
    1. Select org.netbeans.tests.examples.packb.BeanB class in the Project view and invoke Refactor | Move... action from the popup menu.
    2. Select <default package> in To Package combobox and select Preview All Changes checkbox in the Move Class dialog and confirm it by Preview button.
    3. There should be displayed two warnings:
      O If the class is moved to the default package, classes in other packages will not be able to import the moved class.
      O Class you want to move ("BeanB") is using feature "protectedProperty" of class "BeanA" within the same package. Continue by Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Move class BeanB to <default> package [2 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project will not be compilable because of errors in classes BeanB, packa.Bean, packb.BeanC and packb.BeansD.
  4. Drag and Drop
    1. Select AbstractBean and Makable in the org.netbaens.tests.examples.packc , drag them and drop into org.netbeans.tests.examples.packa.
    2. Move dialog will be displayed. List of Classes contains both selected classes. Confirm dialog by the Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Move Classes [16 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project should be compilable.
  5. To Test Packages
    1. Switch to Files view and add test/org/netbeans/tests folder into root folder of default project.
    2. Select org.netbeans.tests.examples.packc.BeanE class in Source Packages in Projects view.
    3. Invoke Refactor | Move... action from the popup menu
    4. Select Test Packages in Location combobox, select org.netbeans.tests in To Package combobox and confirm it by Preview button.
    5. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Move class BeanE to org.netbeans.tests package [2 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project should be compilable.


Test suite: Change Method Parameters

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.
Setup: Project default is needed in this test suite.

  1. Constructor
    1. Put caret over constructor BeanA() from the org.netbeans.tests.examples.packb.BeanA class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog press the Add button and fill Type, Name and Default Value for new created parameter as java.lang.String, name and "".
    3. Press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of constructor to public (java.lang.String name) [4 occurrences]
      should be displayed on the first line of Refactoring window. All occurrences of this constructor should be changed to BeanA("").
  2. Add parameter
    1. Put caret over method abc() from the org.netbeans.tests.examples.packa.Bean class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog press the Add button and fill Type and Name for the new created parameter as int and id. Leave Default Value field empty.
    3. There should be displayed an error notice "Error: You have to provide default values for all new parameters." Fill Default Value as 0.
    4. Press Preview button.
    5. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Change parameters of abc method to public org.netbeans.tests.examples.packa.Bean abc(int id) [12 occurrences]
      should be displayed on the first line of Refactoring window. All occurrences of this method should be changed to abc(0).
  3. Visibility Modifier
    1. Put caret over method abc() from the org.netbeans.tests.examples.packa.Bean class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog select protected in the Access Modifier checkbox.
    3. Press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of abc method to protected org.netbeans.tests.examples.packa.Bean abc() [4 occurrences]
      should be displayed on the first line of Refactoring window.
  4. Remove parameter
    1. Select method make(int index, String s, Bean bean) from the org.netbeans.tests.examples.packc.Makable class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog select "bean" parameter and press the Remove button.
    3. Notice that Access Modifier combobox is disabled for interfaces.
    4. Press Preview button.
    5. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of make method to public abstract void make(int index, java.lang.String s) [10 occurrences]
      should be displayed on the first line of Refactoring window.
  5. Parameter position
    1. Put caret over make(int index, String s, Bean bean) in the org.netbeans.tests.examples.packc.Makable class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog select "s" parameter and press the Move Up button.
    3. Press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of make method to public abstract void make(String s, int index, Bean bean) [24 occurrences]
      should be displayed on the first line of Refactoring window. Project should be compilable.
  6. Vararg
    1. Put caret over make(int index, String s, Bean bean) in the org.netbeans.tests.examples.packc.Makable class and invoke Refactor | Change Method Parameters action from the popup menu.
    2. Add new argument of type int..., set name to vararguments and enter 1,2,3 as default value.
    3. Try to move it to the different position than last.
    4. Press Preview and perform refactoring.
    • EXPECTED RESULT: Change parameters of make method to public abstract void make(String s, int index, Bean bean, int... vararguments) [10 occurrences]
      should be displayed on the first line of Refactoring window. The refactoring cannot continue if vararg parameter is not at the last position. If refactoring is performed method declaration is modified as expected and provided default values are added to all calls of refactored method. Project should be compilable.


Test suite: Encapsulate Fields

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.
Setup: Project Encapsulate is needed in this test suite.

  1. Encapsulate field
    1. Put caret over field field from the MainClass.
    2. Invoke Refactor | Encapsulate Fields... action from the popup menu.
    3. Leave all options at default, press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Encapsulate fields in class encapsulate.MainClass [8 occurrences]
      should be displayed on the first line of Refactoring window. The getter/setter are generated, modifier of the field is changed to desired value (private by default) and all usages are replaced by calls of getter or setters. Project should be compilable.
  2. Change getter, setter name, modifier
    1. Put caret over field field from the MainClass.
    2. Invoke Refactor | Encapsulate Fields... action from the popup menu.
    3. Change getter/setter name and its modifier.
    4. Press Preview button.
    5. If you agree with these changes press Do Refactoring button.
    • EXPECTED RESULT: Encapsulate fields in class encapsulate.MainClass [8 occurrences]
      should be displayed on the first line of Refactoring window. The getter/setter has correct name and the modifiers are as specified in dialog.
  3. Use Accessors if needed
    1. Call Encapsulate field on field x in class Access.
    2. Change visibility modifier to protected.
    3. Uncheck "Use Accessors Even When Field Is Accessible" checkbox.
    4. Press Preview and inspect proposed changeds.
    5. Preform refactoring.
    • EXPECTED RESULT: Encapsulate fields in class encapsulate.Access [4 occurrences]
      should be displayed on the first line of Refactoring window. Getter and setter are generated, visibility modifier is changed. Accessors are used only in class AccessB.
  4. Usage in constructor
    1. Call Encapsulate field on field y in class Ctor.
    2. Set field visibility to private, accessors visibility to public, select "Use Accessors Even When Field Is Accessible".
    3. Perform refactoring.
    • EXPECTED RESULT: Warning about usage in constructor is displayed.
  5. Nothing to encapsulate
    1. Call Encapsulate field in class EmptyClass.
    • EXPECTED RESULT: Dialog stating that EmptyClass has no fields is shown.
  6. Existing methods
    1. Call Encapsulate field on field a in class ExMethod.
    2. Keep defaults name, set field visibility modifier to protected and accessors visibility to public.
    3. Perform refactoring.
    • EXPECTED RESULT: A dialog with "No Patterns Found" shows up. The modifier are not changed, since they already exists.


Test suite: Miscellaneous

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.
Setup: Project default is needed in this test suite.

  1. Undo/Redo
    1. Perform some previous testcase (Rename, Change Method Parameters...) and invoke Undo action.
    2. Verify if changes were reverted to the initial state.
    3. Invoke Redo action.
    4. Verify if changes were same like after refactoring.
    • EXPECTED RESULT: Undo/Redo action works as expected.
  1. Same name in two projects
    1. Create a new General | Java Application project called JavaApplication1; with a main class Main in the package abc.
    2. Create a another new General | Java Application project called JavaApplication2; with a main class Main in the package abc.
    3. Create a new class Alfa in the package abc for JavaApplication1 project.
    4. Create a new class Beta in the package abc for JavaApplication2 project.
    5. Invoke Refactor | Rename action from the popup menu for the abc.Beta in the JavaApplication2 project.
    6. Fill a new class name Alfa in the Rename dialog and confirm this dialog.
    • EXPECTED RESULT: Class Beta from JavaApplication2 project should be renamed to Alfa.
  1. Preview window
    1. Open preview for refactoring (any of the earlier described testcases)
    2. Try function of the buttons in the left part
    3. Click on some item in the tree
    4. Double click on some item in the tree
    • EXPECTED RESULT: The buttons in the right has following functions
    • Refresh refactoring data - brings back refactoring dialog, the values in the should in the state as they were when button Preview was pressed
    • Expand/Collapse all Node - expands/collapses the tree of refactoring preview
    • Show logical view - changes refactoring tree to show hierarchical package structure
    • Show physical view - the tree shows only project and files where the changes will be performed
    • Previous Occurrence, Next Occurrence - jumps to previous/next node in the refactoring tree
    • Click on item opens and or set the preview to show related change (if available)
    • Double click shows related position in the main editor.
  1. Preview window - shortcut
    1. Open preview for refactoring (any of the earlier described testcases).
    2. Try shortcuts Ctrl-comma, Ctrl-period.
    • EXPECTED RESULT: The caret jump on next/previous item in result as when clicking on arrow button in left panel.
  1. Customize refactoring
    1. Open preview for any rename refactoring.
    2. Uncheck several refactoring elements in the refactoring tree.
    3. Perform refactoring.
    • EXPECTED RESULT: The unselected changes are not performed - not shown in preview and not performed in the code itself.
  1. Concurrent modification
    1. Call Rename refactoring on class org.netbeans.tests.examples.packa.Bean .
    2. Enter new name and press button Preview.
    3. While preview is opened change significantly class Bean (e.g. add several new lines).
    • EXPECTED RESULT: The preview shows gray label Rename ..... NEEDS REFRESH and the Do Refactoring button is disabled.
  1. Find usages window
    1. Close 'Usages' window.
    2. Go to Window -> Output -> Find Usages Results.
    • EXPECTED RESULT: The empty window 'Usages' is opened in output area.
  1. Refactoring preview window
    1. Close 'Refactoring' window.
    2. Go to Window -> Output -> Refactoring Preview.
    • EXPECTED RESULT: The empty window 'Refactoring' is opened in output area.
  1. Refactoring preview window - panels
    1. Perform several find usages in a row.
    2. Right click on tab in 'Usages' window.
    3. Try 'Close Tab', 'Close All', 'Close Others Tabs' actions.
    • EXPECTED RESULT: The required tabs are closed.


Test suite: JDK 1.5 Refactoring

Purpose: This test suite tests overall refactoring on JDK1.5 sources.
Setup: These steps are required to be possible to go through following part of the test specification.

  • Unzip a project default2 from default15_TS_60_Refactoring.zip to some work directory.
  • Start IDE with a clean userdir and JDK >= 1.5
  • Invoke File | Open Project... action
  • Select unzipped projects default2
  • Scanning structure of project should be performed (It takes a while)

  1. Refactoring 1.5 - Find Usages
    1. Open package abc.
    2. Find usages of class abc.A.
    • EXPECTED RESULT: Usages of the A should be found. 17 occurrences if 'Search in comments' is unchecked, 22 otherwise.
  1. Refactoring 1.5 - Find Usages - Context
    1. Open annotation abc.def.DAnnotType in the editor and select X of En in default value of member coord in source text.
    2. Invoke the context menu and choose Find Usages.
    3. Find Usages dialog should contain title: "Finx X of class En":.
    4. Select Search in Comments checkbox.
    5. Invoke dialog by Next button.
    • EXPECTED RESULT: It should find 4 occurrences of En.X constant.
  2. Refactoring 1.5 - Rename Class
    1. Open class abc.A in the editor.
    2. Find node correspoding to class abc.A in the explorer (projects view).
    3. Invoke the context menu and choose Refactor/Rename....
    4. Change name to TestClassName.
    • EXPECTED RESULT: Verify that the result is correct - the project is compilable and the class was renamed. 27 [22 is not renaming in comments) occurrences are found and updated.
  3. Refactoring 1.5 - Rename Generics
    1. Open class abc.A in the editor.
    2. Put cursor over T in the class declaration
    3. Invoke the context menu and choose Refactor/Rename....
    4. Change name to X.
    • EXPECTED RESULT: Verify that the result is correct (the project is compilable and the identifier was renamed).
  4. Refactoring 1.5 - Rename Enumeration
    1. Open enumeration abc.En in the editor.
    2. Find node correspoding to enumeration abc.En in the explorer (projects view).
    3. Invoke the context menu and choose Refactor/Rename....
    4. Change name to TestEnumeration.
    • EXPECTED RESULT: Verify that the result is correct (the project is compilable and the enumeration was renamed). 25 [22 - if not renaming in commantes) occurrences were updated.
  5. Refactoring 1.5 - Rename Enumeration Constant
    1. Open enumeration abc.En in the editor.
    2. Put caret over X constant in editor.
    3. Invoke the context menu and choose Refactor/Rename....
    4. Change name to W and select Preview All Changes and Apply Rename in Comments checkboxes.
    5. Confirm dialog by Next button.
    • EXPECTED RESULT: It should find 5 occurrences of the constant.
  6. Refactoring 1.5 - Rename Field
    1. Open class abc.A in the editor.
    2. put caret over field list in the editor.
    3. Invoke the context menu and choose Refactor/Rename....
    4. Change name to testFieldName.
    • EXPECTED RESULT: Verify that the result is correct (the project is compilable and the field was renamed). 5 occurrences were updated.
  7. Refactoring 1.5 - Rename Annotation Type
    1. Open annotation abc.def.DAnnotType in the editor and select DAnnotType in source text.
    2. Invoke the context menu and choose Refactor/Rename....
    3. Change name to AnnotType and press Preview
    • EXPECTED RESULT: It should find 17 [13 if 'Apply Rename on Comments' is unchecked) occurrences of the annotation type.
  8. Refactoring 1.5 - Rename Annotation Type Member
    1. Open annotation abc.def.DAnnotType in the editor and select coord member in source text.
    2. Invoke the context menu and choose Refactor/Rename....
    3. Change name to dcoord and press Preview button
    • EXPECTED RESULT: It should find 2 occurrences of the member of annotation type.
  9. Refactoring 1.5 - Move Class I
    1. Open class abc.A in the editor.
    2. Find node correspoding to class abc.A in the explorer (projects view).
    3. Invoke the context menu and choose Refactor/Move Class....
    4. Set destination package to abc.def.
    • EXPECTED RESULT: Verify that the result is correct (the project is compilable and the class was moved). 14 occurrences were updated.
  10. Refactoring 1.5 - Move Class II
    1. Open enumeration abc.En in the editor.
    2. Find node correspoding to enumeration abc.En in the explorer (projects view).
    3. Invoke the context menu and choose Refactor/Move Class....
    4. Set destination package to abc.def.
    • EXPECTED RESULT: Verify that the result is correct (the project is compilable and the enumeration was moved). 8 occurrences were updated.
  11. Refactoring 1.5 - Encapsulate Fields
    1. Open class abc.A in the editor.
    2. Put caret over field list.
    3. Invoke the context menu and choose Refactor/Encapsulate Fields....
    4. Leave the default values in the dialog untouched (encapsulate only list , field visibility private , accessor visibility public , use accesors even if field is visible true.
    • EXPECTED RESULT: Verify that the result is correct (all occurrences of list in abc.A and abc.B should be replaced, the generated methods should have generics types).
  12. Refactoring 1.5 - Change Signature
    1. Open class abc.A in the editor.
    2. Put caret over field abc.A.methodA(T, String, boolean, String...) in the editor.
    3. Invoke the context menu and choose Refactor/Change Method Parameters....
    4. Make some changes.
    • EXPECTED RESULT: Verify that the result is correct.


Generated: Tue May 22 17:11:15 CEST 2007

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo