Now I am learning Junit5 framework, and I found out there is an option to run my unit-test not only with IDE (I am using IntelijIdea), but with Maven surefire plugin. A lot of articles in the Ethernet advice me to use Maven plugin to run my test. Perhaps, I am not understand something, but whats the point? Actually, I can use my default IDE options to run it, am I wrong? Thanks a lot!
While inside IntelliJ, use that to run your unit tests. That's where you write your code, run the unit tests there too, while working on your code.
If you're just starting with this, that may be the only place where you ever run your unit tests. But in any kind of mature development project, particularly when collaborating on code, you want a way to build your project outside your editor or IDE. While an IDE is often tainted with personal preferences and such, a build (script) on the command-line is seen as more authoritative.
If you have a good build (script) on the command-line, you can also run it in a Continuous Integration environment ("build server"), and properly automate builds, testing, reporting and deployments.
In this age, do not make your own build script for Java projects. Maven is the gold standard.
At the bare minimum, Maven will offer you:
pom.xml
.This is some official documentation about dependency management, and this about the POM (file). But don't get overwhelmed by all the options. Instead, rather rely on Maven's sane defaults.
For example, if you are using IntelliJ, I recommend using it to create your first Maven project, since it will set up a few things in a working POM (file) without you having to immediately understand the format of the POM entirely. (Choose "New Project", select "Maven", skip over archetype selection, and so on.)
Important things to keep in mind here are the POM (file), in the root of the project, and Maven's Standard Directory Layout, most notably for your question src/main/java
and src/test/java
for your production code resp. test code.