Comment on page
Write Tests menu option
Where to find the Write Tests menu option and how it can be used
Write Testsmenu option can be used throughout IntelliJ:
Write Testsmenu 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.
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
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 Testsmenu 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
cmdon MacOS). Cover will attempt to write tests for every class within your selection.
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 Testsmenu option for any method within the structure window.
You can similarly also select multiple methods with
cmdon MacOS) and Cover will attempt to write tests for every method within your selection.
You can similarly find the
Write Testsmenu 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 Testsmenu option will write tests for the method. If you right-click on a class, the
Write Testsmenu option will write tests for the class.
You can also select a range of text in the editor. if you do so, the
Write Testsmenu 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 Testsmenu option will similarly figure out which methods are within any of your selections and will attempt to write tests each method it finds.
Instead of right clicking within the IntelliJ text editor, you can also find a
Write Testsmenu option inside the Diffblue menu bar. Selecting this menu option will perform the exact same function as the menu option in the text editor.