The Unit Test Builder tool helps you generate test cases as you are stepping through code.
Do the following to generate a new test case:
Unit Test Builder supports projects with references to NUnit, XUnit and VSTest frameworks.
Start your debugging session.
Place the caret on a method for which you want to generate a test.
For example, the Square method below should return 9 instead of 6 if you pass 3 to this method:
Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
Click the "Generate Test In" item from the menu and choose the location for a test method from the list.
You can place a test method inside an existing test class, or create a new test fixture.
The red target picker appears after you selected the existing text class item from the "Generate Test In" submenu.
CodeRush shows the Test Builder message box.
This message box informs you that the Unit Test Builder will generate test after you end your debugging session.
Add remarks (optional) in the Test Builder message box. These remarks appear in a test method's comment.
Click OK to close the message box.
End your debugging session to see the generated test.
The screencast below shows these steps in detail.
End your debugging session and see the generated test.