I was viewing a tutorial about Testing, The exhibitor in the video shows how to create a Test on IntelliJ
using Alt + Enter over the name Class. Immediately appears a secondary menu with the option Create Test
.
The good thing about this is that it creates the test class respecting the hierarchy of the package where the original class is located.
As is shown in the next image. Even creates a method name as the original Class. Example: public Examen findExamenPorNombre(String nombre)
and the test class creates a method with void findExamenPorNombre(String nombre)
.
The Question is:
Is there something similar to this feature in Spring Tool Suite 4? Without need to create manually a package hierarchy as the original class.
Yes, there is a quick-fix to create a new JUnit Test class from an existing class. Go to the class name, press Ctrl-1 (or Cmd-1, depending on your system), and select the "Create new JUnit test case" quick fix. It will open and pre-populate the wizard to create a new JUnit test.