TS 67 CNDrefactoring

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