TS 67 CNDrefactoring

(Difference between revisions)
 
(12 intermediate revisions not shown)
Line 1: Line 1:
==Refactoring Test Specification ==
==Refactoring Test Specification ==
'''Author:''' [mailto:Dmitry.Nikitin@sun.com Dmitry Nikitin] <br>
'''Author:''' [mailto:Dmitry.Nikitin@sun.com Dmitry Nikitin] <br>
-
'''Version:''' 0.1 <br>
+
'''Version:''' 1.2 <br>
-
'''Lastupdate:''' <br>
+
'''Lastupdate:''' 08.08.2013 <br>
-
'''Introduction:''' Test specification for refactoring feature in CND Pack 6.7. See [[CND67Refactoring | CND67Refactoring]]<br>
+
'''Introduction:''' Test specification for refactoring feature in CND Pack 7.4 <br>
__TOC__
__TOC__
<br>
<br>
====Test suite: Rename====
====Test suite: Rename====
Purpose: Verify Renaming file, class, macro, function, variable, typedef, namespace in CND Pack<br>
Purpose: Verify Renaming file, class, macro, function, variable, typedef, namespace in CND Pack<br>
-
Comment: See [[CND67Refactoring | CND67Refactoring]], [http://www.netbeans.org/issues/show_bug.cgi?id=136314 IZ#136314]<br>
+
Comment: <br>
# {{testcase|Rename variable}}
# {{testcase|Rename variable}}
Line 23: Line 23:
##Right-click on Memory and select Refactor > Rename from popup menu <br> {{result|'Rename' dialog box appears }}
##Right-click on Memory and select Refactor > Rename from popup menu <br> {{result|'Rename' dialog box appears }}
##Type new name for class and press Preview button <br> {{result|'Refactoring' view will appear. Memory is found in 11 occurrences, in memory.h (2), memory.cc (5) and in quote.cc (4)}}
##Type new name for class and press Preview button <br> {{result|'Refactoring' view will appear. Memory is found in 11 occurrences, in memory.h (2), memory.cc (5) and in quote.cc (4)}}
-
##Press 'Do Refactoring' button <br>{{result|all occurrences of Memory should be renamed}}
+
##Press '''Do Refactor''' button <br>{{result|all occurrences of Memory should be renamed}}
##Build the project (Right-click on project node on Project tab and select Build from popup menu)
##Build the project (Right-click on project node on Project tab and select Build from popup menu)
#* {{result|EXPECTED RESULT: Build successful. It means that class Memory was renamed correctly.}}
#* {{result|EXPECTED RESULT: Build successful. It means that class Memory was renamed correctly.}}
Line 29: Line 29:
##New Project > Sample > C/C++ > Fractal
##New Project > Sample > C/C++ > Fractal
##Open fractal.cc in editor (double click on Fractal > Source Files > fractal.cc on Project tab)
##Open fractal.cc in editor (double click on Fractal > Source Files > fractal.cc on Project tab)
-
##Find line <tt>#define MAXISIZE 500000</tt> (line 37) and select <tt>MAXISIZE</tt> macro
+
##Find line <tt>#define MAXISIZE 500000</tt> (line 43) and select <tt>MAXISIZE</tt> macro
##Press Ctrl+R or select Refactor > Rename from popup menu <br> {{result|Rename dialog box appears }}
##Press Ctrl+R or select Refactor > Rename from popup menu <br> {{result|Rename dialog box appears }}
##Type new name for the macro and press Refactor button
##Type new name for the macro and press Refactor button
Line 35: Line 35:
#{{testcase|Rename function}}
#{{testcase|Rename function}}
##New Project > Sample > C/C++ > Quote
##New Project > Sample > C/C++ > Quote
-
##Open quote.cc in editor (double click on Welcome > Source Files > quote.cc on Project tab)
+
##Open quote.cc in editor (double click on Quote > Source Files > quote.cc on Project tab)
-
##Find function <tt>readNumberOf</tt> (line 87)
+
##Find function <tt>readNumberOf</tt> (line 76)
-
##Click on on <tt>readNumberOf</tt> press Ctrl+R  
+
##Click on on <tt>readNumberOf</tt> press Ctrl+R<br> {{result|Function name is highlighted in blue and a cursor appears in the end of function name }}
##Type new name for the function and press Enter
##Type new name for the function and press Enter
##Save quote.cc (Ctrl+S)
##Save quote.cc (Ctrl+S)
Line 45: Line 45:
##New Project > C/C++ > C/C++ Application
##New Project > C/C++ > C/C++ Application
##Open main.cc in editor (double click on Application > Source Files > main.cc on Project tab)
##Open main.cc in editor (double click on Application > Source Files > main.cc on Project tab)
-
##Add the following code to source file  
+
##Add the following code to source file
<pre>
<pre>
typedef int OldInt;   
typedef int OldInt;   
Line 51: Line 51:
     OldInt i = -1;
     OldInt i = -1;
     return i*MyInt;     
     return i*MyInt;     
-
}  
+
} </pre>
-
</pre>  
+
##Select OldInt in the first line and press Ctrl+R or select Refactor > Rename from popup menu <br> {{result|'Rename' dialog box appears }}
-
 
+
-
###Select OldInt in the first line and press Ctrl+R or select Refactor > Rename from popup menu <br> {{result|'Rename' dialog box appears }}
+
##Type new name for OldInt (e.g. NewInt) and press Refactor button
##Type new name for OldInt (e.g. NewInt) and press Refactor button
#* {{result|EXPECTED RESULT: the code is transformed to
#* {{result|EXPECTED RESULT: the code is transformed to
Line 63: Line 61:
     return i*MyInt;     
     return i*MyInt;     
}  
}  
-
</pre> }}
+
</pre>}}
# {{testcase|Rename namespace}}
# {{testcase|Rename namespace}}
Line 77: Line 75:
}
}
</pre>
</pre>
-
 
##Select <pre>BB</pre> and press Ctrl+R or Right-click and Refactor > Rename from popup menu
##Select <pre>BB</pre> and press Ctrl+R or Right-click and Refactor > Rename from popup menu
##Type new name for <pre>BB</pre> namespace (e.g. <tt>{CC</tt>}) and press Refactor button
##Type new name for <pre>BB</pre> namespace (e.g. <tt>{CC</tt>}) and press Refactor button
#* {{result|EXPECTED RESULT: namespace should be renamed to <pre>CC</pre> and the piece of code should be:
#* {{result|EXPECTED RESULT: namespace should be renamed to <pre>CC</pre> and the piece of code should be:
<pre>
<pre>
-
  <tt>{
+
  {
namespace AA{
namespace AA{
     int var;
     int var;
Line 88: Line 85:
         int var;
         int var;
     }
     }
-
}
+
}</pre>}}
-
</pre> }}
+
====Test suite: Encapsulate field====
====Test suite: Encapsulate field====
Purpose:Verify if this part of refactoring functionality corresponds to design and works right <br>
Purpose:Verify if this part of refactoring functionality corresponds to design and works right <br>
-
Comment: Please, see [http://www.netbeans.org/issues/show_bug.cgi?id=135627 IZ#135627]<br>
+
Comment: <br>
# {{testcase|Encapsulate filed }}
# {{testcase|Encapsulate filed }}
-
## TBD
+
##New Project > Sample > C/C++ > Quote
 +
##Open customer.h in editor (double click on Quote > Header Files > customer.h on Project tab)
 +
##Add private field 'age' <tt>int age;</tt> and click on <tt>age</tt>
 +
##Right-click and select Refactor > Encapsulate Fields... <br> {{result|Encapsulate Fields dialog box appears }}
 +
##Verify that Create Getter and Create Setter methods are checked for 'age:int' field. Change getter/setter names if it's needed<br>
 +
##Press Preview button and after verifying the changes press '''Do Refactor''' button
 +
##Build the project
 +
#* {{result|EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.}}
 +
  <br>
====Test suite: Change method parameters====
====Test suite: Change method parameters====
Purpose:Verify if this part of refactoring functionality corresponds to design and works right <br>
Purpose:Verify if this part of refactoring functionality corresponds to design and works right <br>
-
Comment: Please, see [http://www.netbeans.org/issues/show_bug.cgi?id=153818 IZ#153818]<br>
+
Comment: <br>
    
    
# {{testcase|Adding new method parameters}}
# {{testcase|Adding new method parameters}}
##New Project > Sample > C/C++ > Quote
##New Project > Sample > C/C++ > Quote
##Open system.cc in editor (double click on Quote > Source Files > system.cc on Project tab)
##Open system.cc in editor (double click on Quote > Source Files > system.cc on Project tab)
-
##Go to line 65 <tt>output << system.GetModule(i) << endl;</tt>  and click on <tt>GetModule</tt>
+
##Go to line 66 <tt>output << system.GetModule(i) << endl;</tt>  and click on <tt>GetModule</tt>
##Right-click and select Refactor > Change Method Parameters ... <br> {{result|Change Method Parameters dialog box appears }}
##Right-click and select Refactor > Change Method Parameters ... <br> {{result|Change Method Parameters dialog box appears }}
##Press Add button and type new parameter name, type and default value. <br> '''NB:''' Default value is parameter's value which will be passed to function
##Press Add button and type new parameter name, type and default value. <br> '''NB:''' Default value is parameter's value which will be passed to function
-
[[Image:http://wiki.netbeans.org/attach/TS_67_CNDrefactoring/Screenshot-Change Method Parameters.png]]
+
##Press Preview button and after verifying the changes press '''Do Refactor''' button  
-
##Press Preview button and after verifying the changes press 'Do Refactoring' button  
+
##Build the project
##Build the project
#* {{result|EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.}}
#* {{result|EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.}}
Line 115: Line 118:
##New Project > Sample > C/C++ > Quote
##New Project > Sample > C/C++ > Quote
##Open system.cc in editor (double click on Quote > Source Files > system.cc on Project tab)
##Open system.cc in editor (double click on Quote > Source Files > system.cc on Project tab)
-
##Go to line 65 <tt>output << system.GetModule(i) << endl;</tt>  and click on <tt>GetModule</tt>
+
##Go to line 66 <tt>output << system.GetModule(i) << endl;</tt>  and click on <tt>GetModule</tt>
-
##Add new parameter to <tt>GetModule</tt> method. See testcase {{testcase|Adding new method parameters}} above.
+
##Add new parameter to <tt>GetModule</tt> method. See testcase {{testcase|Adding new method parameters}} above. <br> '''NB:''' new added parameter will be deleted in the next several steps <br> Now we are going to remove the parameter
-
  <br> '''NB:''' new added parameter will be deleted in the next several steps
+
-
  <br> Now we are going to remove the parameter
+
##Right-click and select Refactor > Change Method Parameters ... <br> {{result|Change Method Parameters dialog box appears }}
##Right-click and select Refactor > Change Method Parameters ... <br> {{result|Change Method Parameters dialog box appears }}
##Select unused parameter and press Remove button  
##Select unused parameter and press Remove button  
-
##Press Preview button and after verifying the changes press 'Do Refactoring' button  
+
##Press Preview button and after verifying the changes press '''Do Refactor''' button  
##Build the project
##Build the project
#* {{result|EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.}}
#* {{result|EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.}}
   <br>
   <br>
-
# {{testcase|Changing name, type, value of existing parameters}}
 
-
## TBD
 
-
  <br>
 
-
# {{testcase|Changing Access Modifier}}
 
-
## TBD
 
-
 
-
}}
 

Current revision as of 13:57, 8 August 2013

Refactoring Test Specification

Author: Dmitry Nikitin
Version: 1.2
Lastupdate: 08.08.2013
Introduction: Test specification for refactoring feature in CND Pack 7.4

Contents


Test suite: Rename

Purpose: Verify Renaming file, class, macro, function, variable, typedef, namespace in CND Pack
Comment:

  1. Rename variable
    1. New Project > Sample > C/C++ > Welcome
    2. Open welcome.cc in editor (double click on Welcome > Source Files > welcome.cc on Project tab)
    3. Find line: int main(int argc, char**argv) { and click on argc
    4. Right-click on argc and select Refactor > Rename from popup menu (or Ctrl+R)
    5. Type new name for argc (e.g. arg_count) and press Enter
    • EXPECTED RESULT: all occurrences of argc are renamed to arg_count.
  2. Rename class
    1. New Project > Sample > C/C++ > Quote
    2. Open memory.h in editor (double click on Quote > Header Files > memory.h on Project tab)
    3. Find line class Memory : public Module { and click on class name Memory
    4. Right-click on Memory and select Refactor > Rename from popup menu
      'Rename' dialog box appears
    5. Type new name for class and press Preview button
      'Refactoring' view will appear. Memory is found in 11 occurrences, in memory.h (2), memory.cc (5) and in quote.cc (4)
    6. Press Do Refactor button
      all occurrences of Memory should be renamed
    7. Build the project (Right-click on project node on Project tab and select Build from popup menu)
    • EXPECTED RESULT: Build successful. It means that class Memory was renamed correctly.
  3. Rename macro
    1. New Project > Sample > C/C++ > Fractal
    2. Open fractal.cc in editor (double click on Fractal > Source Files > fractal.cc on Project tab)
    3. Find line #define MAXISIZE 500000 (line 43) and select MAXISIZE macro
    4. Press Ctrl+R or select Refactor > Rename from popup menu
      Rename dialog box appears
    5. Type new name for the macro and press Refactor button
    • EXPECTED RESULT: all occurrences of MAXISIZE should be renamed
  4. Rename function
    1. New Project > Sample > C/C++ > Quote
    2. Open quote.cc in editor (double click on Quote > Source Files > quote.cc on Project tab)
    3. Find function readNumberOf (line 76)
    4. Click on on readNumberOf press Ctrl+R
      Function name is highlighted in blue and a cursor appears in the end of function name
    5. Type new name for the function and press Enter
    6. Save quote.cc (Ctrl+S)
    7. Build the project (Right-click on project node on Project tab and select Build from popup menu)
    • EXPECTED RESULT: Build successful. It means that function readNumberOf was renamed correctly.
  5. Rename typedef
    1. New Project > C/C++ > C/C++ Application
    2. Open main.cc in editor (double click on Application > Source Files > main.cc on Project tab)
    3. Add the following code to source file
typedef int OldInt;  
OldInt MyInt(OldInt MyInt){
    OldInt i = -1;
    return i*MyInt;    
} 
    1. Select OldInt in the first line and press Ctrl+R or select Refactor > Rename from popup menu
      'Rename' dialog box appears
    2. Type new name for OldInt (e.g. NewInt) and press Refactor button
    • EXPECTED RESULT: the code is transformed to
typedef int NewInt;  
NewInt MyInt(NewInt MyInt){
    NewInt i = -1;
    return i*MyInt;    
} 
  1. Rename namespace
    1. New Project > Sample > C/C++ > Welcome
    2. Open welcome.cc in editor (double click on Welcome > Source Files > welcome.cc on Project tab)
    3. Add the following code
namespace AA{
    int var;
    namespace BB{
        int var;
    }
}
    1. Select
      BB
      and press Ctrl+R or Right-click and Refactor > Rename from popup menu
    2. Type new name for
      BB
      namespace (e.g. {CC}) and press Refactor button
    • EXPECTED RESULT: namespace should be renamed to
      CC
      and the piece of code should be:
 {
namespace AA{
    int var;
    namespace CC{
        int var;
    }
}

Test suite: Encapsulate field

Purpose:Verify if this part of refactoring functionality corresponds to design and works right
Comment:

  1. Encapsulate filed
    1. New Project > Sample > C/C++ > Quote
    2. Open customer.h in editor (double click on Quote > Header Files > customer.h on Project tab)
    3. Add private field 'age' int age; and click on age
    4. Right-click and select Refactor > Encapsulate Fields...
      Encapsulate Fields dialog box appears
    5. Verify that Create Getter and Create Setter methods are checked for 'age:int' field. Change getter/setter names if it's needed
    6. Press Preview button and after verifying the changes press Do Refactor button
    7. Build the project
    • EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.
 

Test suite: Change method parameters

Purpose:Verify if this part of refactoring functionality corresponds to design and works right
Comment:

  1. Adding new method parameters
    1. New Project > Sample > C/C++ > Quote
    2. Open system.cc in editor (double click on Quote > Source Files > system.cc on Project tab)
    3. Go to line 66 output << system.GetModule(i) << endl; and click on GetModule
    4. Right-click and select Refactor > Change Method Parameters ...
      Change Method Parameters dialog box appears
    5. Press Add button and type new parameter name, type and default value.
      NB: Default value is parameter's value which will be passed to function
    6. Press Preview button and after verifying the changes press Do Refactor button
    7. Build the project
    • EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.
 
  1. Removing method parameters
    NB: You can remove only parameters which aren't used in method's body.
    1. New Project > Sample > C/C++ > Quote
    2. Open system.cc in editor (double click on Quote > Source Files > system.cc on Project tab)
    3. Go to line 66 output << system.GetModule(i) << endl; and click on GetModule
    4. Add new parameter to GetModule method. See testcase Adding new method parameters above.
      NB: new added parameter will be deleted in the next several steps
      Now we are going to remove the parameter
    5. Right-click and select Refactor > Change Method Parameters ...
      Change Method Parameters dialog box appears
    6. Select unused parameter and press Remove button
    7. Press Preview button and after verifying the changes press Do Refactor button
    8. Build the project
    • EXPECTED RESULT: The Project is built successful. It means that refactoring didn't break code.
 
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