Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify test directory in Maven pom.xml [duplicate]

Maven handles java unit tests well by defaulting to:

src/test/java

We're writing quite a few Groovy unit tests right now, and I'd like to find a way in Maven to specify a folder such as:

src/test/groovy

as a test folder. This would help us to import a Maven project into, say, IntelliJ, without additional setup.

Someone mentioned this was possible, but I wasn't able to find a way searching the Maven docs, or SO. Does anyone know how to mark the directory in the pom?

Thank you

Update: I am not asking how to run the tests in Maven! The tests are already running fine. I'm asking how to mark the directories as test directories in Maven.

like image 508
orbfish Avatar asked Jul 31 '15 20:07

orbfish


People also ask

What is test folder in Maven project?

As per the Maven configurations, tests class will be found in the src/test directory and the source code will be found in the src/main directory. So src/main/java is the root directory for your source code & src/test/java/ is the root directory for your test code.

What is the target directory in Maven?

The target directory is used to house all output of the build. The src directory contains all of the source material for building the project, its site and so on. It contains a subdirectory for each type: main for the main build artifact, test for the unit test code and resources, site and so on.

How do I run the Maven test clean?

We can run our unit tests with Maven by using the command: mvn clean test. When we run this command at command prompt, we should see that the Maven Surefire Plugin runs our unit tests. We can now create a Maven project that compiles and runs unit tests which use JUnit 5.

What is Maven directory structure?

The Maven directory structure is a standard directory structure which Maven expects to build a project. You do not have to follow the Maven directory structure, but it is much easier if you do, and it also makes it easier for other developers to understand your project directory structure.


1 Answers

As described at http://maven.apache.org/ref/3.3.3//maven-model/maven.html#class_build the build section of the pom.xml has an entry to specify the test folder.

like image 133
Robert Scholte Avatar answered Sep 24 '22 01:09

Robert Scholte