Search code examples
javaeclipsemaventycho

Test source directory Maven


I have a multi-module Maven3 project and I want to trigger JUnit testing. The current structure of the project is the following:

-- plugin
    |-- src
    |   |-- [package]
    |   |   -- [source code]
    |   |       
    |-- src-test
    |   |-- [package]
    |   |   -- [unit tests]
    |   |
    |   -- resources

If I move the src-test folder in the src folder the tests are working just fine. But I want to avoid changing the structure of the project.

I've already tried with <testSourceDirectory> tag in the pom but it didn't worked.

 <parent>
    <groupId>xxxx</groupId>
    <artifactId>xxxx</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>xxxx</groupId>
  <artifactId>yyyy</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>eclipse-test-plugin</packaging>

  <build>

    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>src-test</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-surefire-plugin</artifactId>
        <version>0.24.0</version>
        <configuration>

          <includes>
              <include>**/*Test.java</include>
          </includes>
          <useUIHarness>false</useUIHarness>
          <providerHint>junit4</providerHint>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Is there any solution? Thank you in advance!


Solution

  • I've managed to find a solution to this. I've added the src-test folder to the build.properties of the plugin.