With UnitTestBot you can generate tests
- for a package,
- for a single class or a set of classes,
- for a method or a set of methods.
- Open your Java project in IntelliJ IDEA.
- Choose the required package, class or set of classes in the Project tool window.
Right-click and choose Generate Tests with UnitTestBot... or press Alt+Shift+U.
- Alternatively, in the Editor, place the caret at the required class or method.
Press Alt+Shift+U or right-click and choose Generate... > Tests with UnitTestBot.
- In the Generate Tests with UnitTestBot window tick the classes or methods you'd like to cover with tests and press Generate Tests or Generate and Run.
Now you can see the resulting test class or classes in the Editor.
Note: if you re-generate the test for a given class or method, it will erase the previously generated test for this unit. To prevent this, rename or move the tests you want to keep. For more information see Test sources root.