TS 73 InspectAndRefactor

Inspect And Transform

Author:Jiri Prox
Version:7.3
Last update:2012/11/08
Introduction:This is test specification for Inspect and Refactor feature. This functionality allows user to run set of refactoring (hints) and once on the selected scope of files. User can even define his own hint.

Contents

Test suite: Applying Hints

  1. Single hint with refactoring
    1. Open InspectRefactor.java file and open Inspect&Transform dialog
    2. Select Single Inspection and choose Assignment replaceble with operator ... hint
    3. Press Inspect
    4. Check suggested changes in preview panel and accept them by pressing Do Refactoring
    • EXPECTED RESULT: One occurrence of replaceable assignment is found. In preview there is suggested how to replace it with one operator. After pressing Do Refactoring the suggested changes are applied in code
  2. Preview panel
    1. Repeat previous testcase until refactoring preview is shown
    2. Try functionality of each button in the left part of preview part of the preview window
    3. Try unchecking some checkbox in the tree
    4. Cancel refactoring
    • EXPECTED RESULT: The buttons in the left has correct behaviour. Refresh button reopens Inspect&Transform' dialog.
  3. No patterns found
    1. Open InspectRefactor.java' file and show Inspect&Transform dialog
    2. Select Single Inspection and choose Nested assignment
    3. Press Inspect
    • EXPECTED RESULT: Dialog with text No pattern is found' is opened
  4. Predefined set of hints
    1. Open PredefinedSet.java and open Inspect&Transform dialog
    2. Select Configuration and choose Convert to JDK 7
    3. Press Inspect
    4. Apply suggested refactoring
    • EXPECTED RESULT: Changes conversing project to JDK 7 syntax are suggested (In preview there are 13 occurrence provided) after applying changes the code is changed - diamond operator, string switch and try with resources are provided

Test suite: Managing Configurations

  1. Create new configuration
    1. Open Inspect & Transform dialog
    2. Select Configuration and press Manage... button
    3. From configurations combo box select New...
    4. Type name of new configuration
    5. Choose set of hints
    6. Apply set of hint to the code
    • EXPECTED RESULT: New configuration is created and can by applied to the code
  2. Update configuration
    1. Open Inspect & Transform dialog
    2. Press Manage ... to update configuration
    3. Select configuration created in previous test case
    4. Update set of hint - add some and remove the original ones
    5. Apply modified configuration to the code
    • EXPECTED RESULT: Configuration is modified, hints removed are not used any more,
  3. Rename configuration
    1. Open Inspect & Transform dialog
    2. Press Manage ... to update configuration
    3. Select configuration from previous testcase
    4. Select rename and type new name
    • EXPECTED RESULT: Configuration is renamed
  4. Duplicate configuration
    1. Open Inspect & Transform dialog
    2. Press Manage ... to update configuration
    3. Select configuration from previous testcase
    4. Select duplicate and type new name
    5. Try applying new configuration to the code
    • EXPECTED RESULT: The configuration is copied - the selected hints are the same as in original configuration
  5. Delete configuration
    1. Open Inspect & Transform dialog
    2. Press Manage ... to update configuration
    3. Select configuration from previous testcase
    4. Select delete from the configurations combo box
    • EXPECTED RESULT: Configuration is deleted

Test suite: Scope

  1. File scope
    1. Open InspectRefactor.java
    2. Open Inspect & Transform dialog
    3. Select single inspection - Assignment to method parameter
    4. Select Current File scope
    5. Press Inspect
    • EXPECTED RESULT: Only occurrences from current file are found
  2. Package scope
    1. Repeat previous testcase but select Current package scope
    • EXPECTED RESULT: Occurrences from current package are found (2 occurrences)
  3. Actual project scope
    1. Repeat previous testcase but select Current project scope
    • EXPECTED RESULT: Occurrences from current project are found (3 occurrences)
  4. All opened project
    1. Repeat previous testcase but select All projects scope
    • EXPECTED RESULT: Occurrences from all project are found
  5. Custom scope
    1. Repeat previous testcase but select Custom scope
    2. Press ... button next to the selected scope
    3. Customize scope by checking/un-checking boxes
    4. Confirm scope by OK button and press Inspect
    • EXPECTED RESULT: Occurrences are found only in selected scope
  6. Preset scope
    1. Invoke Inspect&Transform from editor
    2. Invoke Inspect&Transform from context menu in project view - file node
    3. Invoke Inspect&Transform from context menu in project view - package node
    4. Invoke Inspect&Transform from context menu in project view - project node
    • EXPECTED RESULT: Every time dialog is opened, the scope is set according the position where it was invoked

Test suite: Custom Hints

  1. Creating custom hint
    1. Open Inspect&Transform dialog
    2. Press Browse ... for single inspection
    3. Press New... in the bottom of the dialog
    4. Click on Edit Script
    5. Create custom hint (code is in customHint.txt)
    6. Click on Save and the edit text area is closed
    7. Now click on OK while new custom hint is selected in the Inspections tree
    8. Click on Inspect
    • EXPECTED RESULT:New hint Inspection is created, after applying it on Custom.java one part of code is modified (only the static initializer)
  2. Editing script
    1. Open Inspect&Transform and press Browse... for single inspection
    2. Select hint created in previous test case
    3. press Edit Script
    4. make some modification and press Discard
    5. Press Edit Script' again
    6. Remove all '{' and '}' in the script editor
    7. Apply the hint to the Custom.java
    • EXPECTED RESULT:Modifications are not saved when ending editing with Discard. Changes are saved after pressing Save. The modified script changes two parts of the code.
  3. Opening script in editor
    1. Open script for editing as in previous test case
    2. Press Open In Editor
    3. Do some modifications and save the file
    • EXPECTED RESULT: Script is opened in editor, after saving the file the hint itself is modified
  4. Run single inspection
    1. Open custom hint in editor
    2. Press Shift-F6 (Run single file)
    3. Press Inspect to run inspection
    • EXPECTED RESULT:Inspect&Transform dialog is opened. It has pre-filled the single inspection, user can change only the scope. After Inspect is pressed, the hint is applied to the selected scope
  5. Renaming hint
    1. Open Inspect&Transform and press Manage ... for single inspection
    2. Select some custom hint
    3. Right click and from context menu select Rename
    4. Try also clicking on hint name or pressing F2 to start renaming mode
    5. Type new name and confirm it by enter
    • EXPECTED RESULT: Hint is rename
  6. Deleting hint
    1. Repeat previous test case but instead of Rename choose Delete from contex menu
    • EXPECTED RESULT: Hint is deleted. After deleting last custom hint the whole 'Custom' branch is hidden

Test suite: Inspect

  1. Running single inspection
    1. Open SingleInspection
    2. Call Source -> Inspect
    3. Select Single Inspection and choose Assignment to method parameter
    4. Press Inspect
    5. Try all buttons at the left of the result window, try double click on the leaf of the tree
    • EXPECTED RESULT:One occurrence of assignment to method parameter is found (note that the scope of the search was automatically set to current file only). The tree in result window shows where is the related code. Selecting the tree node show explanation in the right part of the window. Double click on tree node opens the source file and places cursor at proper line. Buttons at the left do following: reopens Inspect dialog with last values, moves to previous occurrence, moves to next occurrence, change the tree ordering.
  2. No patterns found
    1. Open SingleInspection
    2. Run single inspection Pointless bitwise operation on it
    • EXPECTED RESULT:Result window is empty
  3. Running All Analyzers
    1. Open SingleInspection
    2. Open Inspect dialog
    3. Select Configuration and choose All analyzers
    4. Press Inspect
    • EXPECTED RESULT:There may be warning about missing plugin if FindBugs integration is not installed, anyway this does not block Inspection. The inspection searches for all enabled hints - by default it fined 2 problems: missing javadoc and the assigned values is never used (try turning all 'Assignment' hints in options - it will find 4 problems). There may be one problems more it the FindBugs is installed.
  4. Creating configuration
    1. Open SingleInspection
    2. Open Inspect dialog
    3. Select Configuration and press Manage...
    4. From the Configurations checkbox choose New
    5. Select all Assignment issues
    6. Press OK
    • EXPECTED RESULT:Custom configuration newConfig is created, it contains all selected hints.
  5. Running predefined configuration
    1. Open SingleInspection
    2. Open Inspect dialog
    3. Select custom configuration created in previous test case
    4. Press Inspect
    • EXPECTED RESULT:3 assignment issues are found in current file
  6. Renaming configuration
    1. Open Inspect dialog
    2. Select Configuration and press Manage...
    3. Select configuration created in previous test case
    4. Select Rename from the Configurations combo box
    5. Type new name and press enter
    6. Press OK
    • EXPECTED RESULT:Selected configuration is renamed, the new names is correctly propagated to the Inspect dialog. The content of configuration is not changed
  7. Duplicating configuration
    1. Open Inspect dialog
    2. Select Configuration and press Manage...
    3. Select configuration created in previous test case
    4. Select Duplicate from the configurations combobox
    5. Type new name and press enter
    • EXPECTED RESULT:The selected configuration is duplicated. The new configurations has the same content as the original one and the required name
  8. Delete configuration
    1. Open Inspect dialog
    2. Select Configuration and press Manage...
    3. Select configuration created in previous test case
    4. Select Delete from the configurations combobox
    5. Confirm OK
    • EXPECTED RESULT:The selected configuration is deleted
  9. Scope
    1. Select various nodes in project view - file, package, while project
    2. Invoke Inspect dialog
    • EXPECTED RESULT:Scope is set to the correct value according to the context, the action was invoked from.
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