running tests in a maven multi module project

Viewed 58

I have a maven multi project with this pom.xml:

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>booking</groupId>
    <artifactId>booking</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!-- sub modules -->
    <modules>
        <module>b1</module>
        <module>b5</module>
        <module>l1</module>
        <module>l20</module>
    </modules>


</project>

enter image description here

but when I run the tests in the root maven I got this result: No tests to run.

public class CalculationFunctionImplTest {

    @Test
    public void test() {

        CalculationFunctionImpl calculationFunctionImpl = new CalculationFunctionImpl ("time");
        System.out.println(calculationFunctionImpl.calculate());


    }

}
1 Answers

Your main module is of packaging POM (as it should be), but this means that tests are not run in the build lifecycle of the main project.

It is probably best to move the tests to a module.

Related