Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organise unit, integration, e2e tests folder structure in maven for a Java project?

I have a java project in maven and i know maven puts thing conventionally using

  • src/main/java
  • src/test/java

and everything under test/ is usually unit test. But what if i want to introduce integration tests and E2E tests? How should i put in the correct folder structure? What is the correct way to organise these?

could this be it:

  • src/it/java
  • src/e2e/java
  • src/test/java

?

but doing this way would assume src/test/java is referring to unit tests. I rather have a clearly specified

like image 814
SoftwareDeveloper Avatar asked Aug 22 '15 20:08

SoftwareDeveloper


People also ask

How do I run a specific integration test in Maven?

The simplest way to run integration tests is to use the Maven failsafe plugin. By default, the Maven surefire plugin executes unit tests during the test phase, while the failsafe plugin runs integration tests in the integration-test phase.

Can maven be integrated with JUnit test framework?

Junit Framework can be integrated with Eclipse, Ant and Maven, but in this article we will be using Maven.


1 Answers

I would suggest to use the maven defined directory structure - src/test/java. You can change the maven defined directory structure, but it's not recommended. Ideally this structure is meant for unit tests, but you can still add integration and e2e unit tests into that folder structure with little modifications.

Refer to - How to run UnitTests in maven which is in src/test-integration/java folder

like image 94
asg Avatar answered Sep 18 '22 13:09

asg