Atul
Atul

Reputation: 1590

Maven not running tests through eclipse in multimodule project

I have a simple multimodule maven project structure as below :

main-project : 
   -test-child-one : 
   -test-child-three : 
   -test-child-two : 

When I run mvn test through eclipse from inside parent project, no tests are run.

I have also tried running mvn test from inside one of child projects - test-child-one , but tests are not run .

It always shows -

Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

The pom for parent and child are below :

parent pom :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.atul.multimodule</groupId>
  <artifactId>main-project</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>main-project</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <modules>
    <module>test-child-one</module>
    <module>test-child-two</module>
    <module>test-child-three</module>
  </modules>
</project>

child pom :

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.atul.multimodule</groupId>
    <artifactId>main-project</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>com.atul.multimodule</groupId>
  <artifactId>test-child-one</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>test-child-one</name>
  <url>http://maven.apache.org</url>

</project>

Is there anything I am missing here ?

Please help.

Upvotes: 1

Views: 739

Answers (1)

khmarbaise
khmarbaise

Reputation: 97517

The convention over convention paradigm is important related to Maven that means you have a default directory layout and of course naming schemas. This means you have to name your tests accordingly to those schemas.

To define unit tests you should name them like this:

  • **/Test*.java
  • **/*Test.java
  • **/*Tests.java
  • **/*TestCase.java

Upvotes: 3

Related Questions