Mulitple source directory and test directory.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Mulitple source directory and test directory.

softwareforums2013
Hi Everyone

I have source in multiple directorys and test in mulitple directorys. I am reusing my reports. I am successfully able to see unit test report and code coverage. I have added a build-helper-maven plugin to add test source directory. But I am not able to see the test source for testNG.

For example Below is my structure:
Src1
  |--Add.java
  |--Subtract.java

pom.xml for src1 module

Src2
 |--Multiply.java
 |--Divide.java

pom.xml for src2 module

pom.xml (parent pom.xml)

Mockito
  |--AddTest.java
  |--MulitplyTest.java

TestNG
  |--SubtractTest.java
  |--DivideTest.java

So, below is snap shot of parent pom.xml
  <modules>
    <module>access</module>
                <module>src1</module>
                <module>src2</module>
  </modules>
        <properties>
              <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.surefire.reportsPath>../../sonarReports/surefire</sonar.surefire.reportsPath>              <sonar.cobertura.reportPath>../../sonarReports/cobertura/coverage.xml</sonar.cobertura.reportPath>
                <sonar.phase>generate-sources</sonar.phase>
  </properties>

Below is the snap shot of my child pom.xml

        <properties>
              <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.surefire.reportsPath>../../sonarReports/surefire</sonar.surefire.reportsPath>              <sonar.cobertura.reportPath>../../sonarReports/cobertura/coverage.xml</sonar.cobertura.reportPath>
                <sonar.phase>generate-sources</sonar.phase>
  </properties>

<build>
        <sourceDirectory>src1</sourceDirectory>
        <testSourceDirectory>../mockito</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
       </plugin>
           <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                                <execution>
                                        <id>add-test-source</id>
                                        <phase>generate-test-sources</phase>
                                        <goals>
                                                <goal>add-test-source</goal>
                                        </goals>
                                        <configuration>
                                                <sources>
                                                        <source>../testNG</source>
                                                </sources>
                                        </configuration>
                                </execution>
                        </executions>
                </plugin>
       
    </plugins>
  </build>


Below is my snapshot of my 2nd child pom.xml

        <properties>
              <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.surefire.reportsPath>../../sonarReports/surefire</sonar.surefire.reportsPath>              <sonar.cobertura.reportPath>../../sonarReports/cobertura/coverage.xml</sonar.cobertura.reportPath>
                <sonar.phase>generate-sources</sonar.phase>
  </properties>

<build>
        <sourceDirectory>src2</sourceDirectory>
        <testSourceDirectory>../mockito</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
       </plugin>
           <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                                <execution>
                                        <id>add-test-source</id>
                                        <phase>generate-test-sources</phase>
                                        <goals>
                                                <goal>add-test-source</goal>
                                        </goals>
                                        <configuration>
                                                <sources>
                                                        <source>../testNG</source>
                                                </sources>
                                        </configuration>
                                </execution>
                        </executions>
                </plugin>
       
    </plugins>
  </build>



Reply | Threaded
Open this post in threaded view
|

Re: Mulitple source directory and test directory.

Java
Hi,
 
you should stick to the maven way, and put the test cases to their modules. You can define the test dependencies at parent level, but do not confuse your fellow developers by breaking a good maven convention.


Regards,

Hannes

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Mulitple source directory and test directory.

softwareforums2013
we dont have a maven project . We have ant project  and we customize our ant project by adding pom.xml for sonar analysis


On Sat, Nov 2, 2013 at 11:37 AM, Java <[hidden email]> wrote:
Hi,

you should stick to the maven way, and put the test cases to their modules. You can define the test dependencies at parent level, but do not confuse your fellow developers by breaking a good maven convention.


Regards,

Hannes

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email