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

SoftwareDeveloper picture SoftwareDeveloper · Aug 22, 2015 · Viewed 8.5k times · Source

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

Answer

asg picture asg · Aug 23, 2015

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