LuckyLuke
LuckyLuke

Reputation: 49097

Maven unit testing

When unit testing in a multi module maven project do you run the lifecycle face: test. Or should I use the IntelliJ IDEA testing? Maybe I am wrong but I can't see any option to where you can see red/green as you do in non-maven projects. What is preffered?

Upvotes: 1

Views: 244

Answers (3)

Guillaume Polet
Guillaume Polet

Reputation: 47637

It does not really change something, here, that you run a multi-module project. The phases that are executed mainly depends on your packaging type since it defines the lifecycle of your build.

Now, remember that when you choose a phase, Maven will execute all the pre-necessary phases before the one you chose plus the one you chose of course. So for example, if you are running a jar build with phase test, you will have the following phases: process-resources, compile, process-test-resources, test-compile and test (by default, at least).

You can also run the test from your IDE, and the choice is a question of preference and what is easiest for you to use. I prefer the IDE way but any choice is fine.

Upvotes: 1

csturtz
csturtz

Reputation: 6580

For the individual, it doesn't matter. Let the individual run the tests in whatever way works best for them.

However, you'll definitely want to run the maven test lifecycle phase as part of your CI/Release/etc build process no matter what (even if everyone on the team wants to use their IDE)

Upvotes: 1

Oleksi
Oleksi

Reputation: 13097

You can, and should, be using both forms of testing. When you are doing your development, I would run the tests in your IDE because it's convenient. However, when you're done development and check it your code, you should run maven test to ensure every test still passes.

The real perk of having Maven run your tests, is that you can run them automatically on a continuous integration server. Depending on what CI server you use, it might have a user interface that shows you if you had any test fail in a nice pretty way.

Upvotes: 2

Related Questions