Links
Comment on page

Write Tests menu option

Where to find the Write Tests menu option and how it can be used
The Write Tests menu option can be used throughout IntelliJ:
The Write Tests menu option will create tests for your methods and classes but each menu option works slightly differently to produce tests for different parts of your code.

Project Tool Window

When navigating through your project, you'll likely use the project tool window in IntelliJ. You can right-click on any of the elements in this window and you will find a menu option named Write Tests.
If you attempt to use this action after clicking on a folder, Diffblue will attempt to write tests for everything it can find within that package. Note that community edition licenses are limited to writing tests for a single class at a time.
If you attempt to use the Write Tests menu option after clicking on a class, Cover will attempt to write tests for every method in the class. You can also select multiple classes with shift or ctrl (or cmd on MacOS). Cover will attempt to write tests for every class within your selection.

Structure Tool Window

Similarly to the Project Tool Window, IntelliJ provides a Structure menu to help you navigate around your codebase. In particular, the structure menu will show classes, methods and other elements in the currently open file. As with the project tool window, you will find a Write Tests menu option for any method within the structure window.
You can similarly also select multiple methods with shift or ctrl (or cmd on MacOS) and Cover will attempt to write tests for every method within your selection.

Text Editor

You can similarly find the Write Tests menu option in the IntelliJ text editor. If you right click anywhere in the editor, you will find this action. When you click on it, Diffblue will contextually figure out what to write tests for based on the location of your caret within the text. For example, if you right-click on a method, the Write Tests menu option will write tests for the method. If you right-click on a class, the Write Tests menu option will write tests for the class.
You can also select a range of text in the editor. if you do so, the Write Tests menu option will figure out which methods are within your selection and write tests for each of your selected methods.
It is also possible to have multiple cursors or multiple selection ranges within the IntelliJ text editor (see here). When you do so, the Write Tests menu option will similarly figure out which methods are within any of your selections and will attempt to write tests each method it finds.

Diffblue Menu Bar

Instead of right clicking within the IntelliJ text editor, you can also find a Write Tests menu option inside the Diffblue menu bar. Selecting this menu option will perform the exact same function as the menu option in the text editor.