Separating tests from src with a Maven project?

I just started working on a Java project (as I usually use .net), and one of the first things that seems strange to me is that the Maven project has a directory / src and / test, where obviously the source code and tests must go.

In .net, I preferred having tests in a separate assembly / project, so for example, I would:

  • Myproject
  • MyProject.Tests

Thus, I do not need to inflate my deployed code with any tests, and this simplifies the verification of my code in real isolation, and in many cases I did not write tests for one project, I would just have a solution to unit / integration / acceptance tests, t .e. MySolution.UnitTests, MySolution.IntegrationTests.

However, in Java, this seems to merge together, and I would rather separate it, however I heard that Maven is a cruel lover when you want to treat the default structures differently.

So, to enter this post again, my main questions are:

  • Is there a way to separate tests from a project
  • Based on the above information, are there any pros for actual testing within the project? (besides, when you check this, you always have tests).
+3
source share
2 answers

I don't need to inflate my deployed code with any tests

Deployable artifacts (jar file, military files) will not contain test classes or data.

Is there a way to separate tests from a project

"", , "" .

, Maven, , , , (, , ). ( ).

, , , .

// , MySolution.UnitTests, MySolution.IntegrationTests.

. "", , ( ).

+6

maven , .

src/main , - .

maven mar , src/main/java. :

.

+2

Source: https://habr.com/ru/post/1781797/


All Articles