| # | Test case | Description |
| 1 | New method without return statement |
- Open file
packageA.ClassA
- Select text between marks //1 and //2 in the method
noReturn
- Call Refactor -> Extract method
- Check Preview all changes checkbox
- Confirm dialog by clicking on Next without any further changes.
- Inspect the provided changes
- Press Cancel button
- Repeat steps 2) - 6) and in the preview window press Do Refactoring
|
| Teardown: | Undo the refactoring |
|
|
| RESULT: | After step 2: The dialog is popped up. The method's name and access modifier are set. In the Parameters table there are listed all variables that are used in the selected part of the code.
After step 5: New window displaying changes to be made is opened. It's containing all changes which should be performed.
After step 7: The preview window is closed, no changes are done.
After step 8: The new method is created. Its body is formed by the previously selected code. The original selection is replaced by the method call. The class can be compiled.
|
|
| 2 | Method with return statement |
- Open file
packageA.ClassA
- Select the code form mark //3 to //4
- Call Refactor -> Extract Method
- Confirm dialog
- Inspect proposed changes
- Confirm changes
|
| Teardown: | Undo all changes |
|
|
| RESULT: | New method without any parameters is created. The original place is modified that the variable c is initialized by method's call. |
|
| 3 | Method with return statement 2 |
- Open file
packageA.ClassA
- Select the code form mark //4 to //5
- Call Refactor -> Extract Method
- Confirm dialog
- Inspect proposed changes
- Confirm changes
|
| Teardown: | Undo all changes |
|
|
| RESULT: | The new method with two parameters is created. One of the parameters is final the second is ordinary (not final). The method contains return statement. At the original place there is assignment of method's result to a single variable. |
|
| 4 | Ending with return/break/continue |
- Open file
packageA.ClassA
- Mark code between //7 and //8
-
Refactor -> Extract Method
- Confirm all changes and perform refactoring
- Undo changes
- Try to change the
continue command to break and return respectively.
|
| Teardown: | Undo all changes |
|
|
| RESULT: | In the step 3 a new method is created. The original selection is replaced with method call and the last statement (continue;) stays as it is.
|
|
| 5 | Illegal refactoring - wrong selection |
- Open some file
- Try to select part of the command, expression or line and call Extract Method
- Try also selecting whole class and call Extract Method
- Try to select some unsuitable nodes from the project explorer (project root, package node, constructor node etc..) and invoke Extract Method on it
- Try to call Extract Method on items from Navigator (by selecting them and using main menu Refactor
|
|
| RESULT: | In all these cases the Extract Method should be disabled or the error message should be popped up. |
|
| 6 | Illegal refactoring - too many outputs |
- Open file
packageA.ClassA
- Select code between //0 and //1
- Call Refactor | Extract Method
|
| Teardown: | Undo all changes |
|
|
| RESULT: | Error message announcing too many return variables is popped up. |
|
| 7 | Illegal refactoring - selection contains return/break/continue |
- Open file packageA.ClassA
- Mark code between //6 and //7
-
Refactor -> Extract Method
- Try to change the
continue command to break and return respectively and repeat steps 2) and 3).
|
| Teardown: | Undo all changes if any was done. |
|
|
| RESULT: | The error message is popped up after steps 3 and 4 informing about wrong position of continue, break and return respectively in the selected code. |
|
| 8 | Illegal refactoring - method already defined |
- Open file
packageA.ClassA
- Select the code form mark //4 to //5
- Call Refactor -> Extract Method
- Change method name to
existing
- Confirm dialog
- Press Back
- Change method's name to
existing2 and existing3 respectively and go to step 5
|
| Teardown: | Undo refactoring |
|
|
| RESULT: | For existing and existing2 an error dialog is shown, announcing that the method with the same signature already exists. Method's name existing3 is OK |
|
| 9 | Global variables |
- Open file
packageA.ClassA
- Select the code form mark //9 to //10
- Call Refactor -> Extract Method
|
|
|
|
| RESULT: | The new method without any parameter and without return is created. |
|
| 10 | Modifiers manipulation |
- Go back to some previous test case
- Check Declare Static
- Try changing method's name
- Try also invalid method's name
|
|
|
|
| RESULT: | Check if the method signature preview is updated correctly. Check if the new method is generated properly. |
|
| 11 | Static modifier |
- Open file
packageA.ClassA
- Select the code form mark //11 to //12
- Call Extract Method
|
|
|
|
| 12 | Parameters manipulation |
- Go back to some previous test case
- In the refactoring dialog try to change the order of parameters, their types and names
|
| Teardown: | Undo all changes |
|
|
| RESULT: | The method signature is updated according the changes in parameters table. It's not possible to change parameters types and names. |
|
In this suite, there is used special marks in the code to specify the selection. They are formed by number behind comments. For example to select text between marks //1 and //2 means to find out these comments in the text (each is on the separate line) and select all the code between these lines.