You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-users@maven.apache.org by Ed Abshire <ea...@cybersource.com> on 2010/12/08 23:35:53 UTC

Question concerning executing tests from a parent POM.Xml file

So I have the following directory structure:


-          QA

o   Businessobjects

o   Framework

o   Utilities

o   Uimodel

o   Keywords

o   Fixtures

o   Unittests

o   Tests

Under QA, I have a parent pom.xml that includes all the modules to build the projects underneath the QA directory above as one project.

I am trying to set up surefire to execute tests from the tests directory using testing.

Is there a proper way of doing this?


<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>cybs.qa.framework</groupId>
  <version>2.0</version>
  <artifactId>QA-Automation</artifactId>
  <packaging>pom</packaging>
  <modules>
    <module>businessobjects</module>
    <module>framework</module>
                <module>utilities</module>
                <module>uimodel</module>
                <module>keywords</module>
                <module>fixtures</module>
                <module>unittests</module>
                <module>tests</module>
  </modules>

<dependencies>
            <dependency>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                        <version>5.14</version>
                        <scope>test</scope>
            </dependency>
  </dependencies>

            <build>
                        <pluginManagement>
                                    <plugins>
                                                <plugin>
                                                            <groupId>org.apache.maven.plugins</groupId>
                                                            <artifactId>maven-surefire-plugin</artifactId>
                                                            <version>2.6</version>
                                                            <configuration>
                                                                        <workingDirectory>${basedir}\Tests</workingDirectory>
                                                                        <testClassesDirectory>target/classes</testClassesDirectory>
                                                                        <suiteXmlFiles>
                                                                                    <suiteXmlFile>tests\genericTests.xml</suiteXmlFile>
                                                                        </suiteXmlFiles>
                                                            </configuration>
                                                </plugin>
                                    </plugins>
                        </pluginManagement>
            </build>
</project>
_________________________________________
Ed Abshire

RE: Question concerning executing tests from a parent POM.Xml file

Posted by Ed Abshire <ea...@cybersource.com>.
What we are trying to do is have an test automation framework and tools that users can write tests against.

The tests directory is where the users create their tests, and that is what we can to be able to execute.

For unit tests, I concurred and I will be moving those tests underneath their respective areas...

As for the steps 1 and 2, are there examples of this, I'm just now getting my feet wet in the maven world.

-Ed



From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com]
Sent: Thursday, December 09, 2010 1:05 AM
To: surefire-users@maven.apache.org
Cc: Ed Abshire
Subject: Re: Question concerning executing tests from a parent POM.Xml file

Here is what it looks like you are trying to do:

"I am trying to execute the tests of a child module from within a POM project"

If that is the case then you need to:

1. bind an execution of surefire to the aggregator pom and have that execution not inherited.
2. ensure that the aggregator pom depends on all the child poms, and that the child poms do not inherit from the aggregator pom (i.e. it cannot be a parent any more)

And then what it looks like you are trying to do will be done....


BUT

You really don't want to do that.

You are fighting the maven way.

Leave the tests for each module in that module

Put the tests of everything else in their own testing module that depends on the previous modules.

Lather-rinse-repeat

-Stephen

On 8 December 2010 22:35, Ed Abshire <ea...@cybersource.com>> wrote:
So I have the following directory structure:


-          QA

o   Businessobjects

o   Framework

o   Utilities

o   Uimodel

o   Keywords

o   Fixtures

o   Unittests

o   Tests

Under QA, I have a parent pom.xml that includes all the modules to build the projects underneath the QA directory above as one project.

I am trying to set up surefire to execute tests from the tests directory using testing.

Is there a proper way of doing this?


<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>cybs.qa.framework</groupId>
 <version>2.0</version>
 <artifactId>QA-Automation</artifactId>
 <packaging>pom</packaging>
 <modules>
   <module>businessobjects</module>
   <module>framework</module>
               <module>utilities</module>
               <module>uimodel</module>
               <module>keywords</module>
               <module>fixtures</module>
               <module>unittests</module>
               <module>tests</module>
 </modules>

<dependencies>
           <dependency>
                       <groupId>org.testng</groupId>
                       <artifactId>testng</artifactId>
                       <version>5.14</version>
                       <scope>test</scope>
           </dependency>
 </dependencies>

           <build>
                       <pluginManagement>
                                   <plugins>
                                               <plugin>
                                                           <groupId>org.apache.maven.plugins</groupId>
                                                           <artifactId>maven-surefire-plugin</artifactId>
                                                           <version>2.6</version>
                                                           <configuration>
                                                                       <workingDirectory>${basedir}\Tests</workingDirectory>
                                                                       <testClassesDirectory>target/classes</testClassesDirectory>
                                                                       <suiteXmlFiles>
                                                                                   <suiteXmlFile>tests\genericTests.xml</suiteXmlFile>
                                                                       </suiteXmlFiles>
                                                           </configuration>
                                               </plugin>
                                   </plugins>
                       </pluginManagement>
           </build>
</project>
_________________________________________
Ed Abshire


Re: Question concerning executing tests from a parent POM.Xml file

Posted by Stephen Connolly <st...@gmail.com>.
Here is what it looks like you are trying to do:

"I am trying to execute the tests of a child module from within a POM
project"

If that is the case then you need to:

1. bind an execution of surefire to the aggregator pom and have that
execution not inherited.
2. ensure that the aggregator pom depends on all the child poms, and that
the child poms do not inherit from the aggregator pom (i.e. it cannot be a
parent any more)

And then what it looks like you are trying to do will be done....


BUT

You really don't want to do that.

You are fighting the maven way.

Leave the tests for each module in that module

Put the tests of everything else in their own testing module that depends on
the previous modules.

Lather-rinse-repeat

-Stephen

On 8 December 2010 22:35, Ed Abshire <ea...@cybersource.com> wrote:

> So I have the following directory structure:
>
>
> -          QA
>
> o   Businessobjects
>
> o   Framework
>
> o   Utilities
>
> o   Uimodel
>
> o   Keywords
>
> o   Fixtures
>
> o   Unittests
>
> o   Tests
>
> Under QA, I have a parent pom.xml that includes all the modules to build
> the projects underneath the QA directory above as one project.
>
> I am trying to set up surefire to execute tests from the tests directory
> using testing.
>
> Is there a proper way of doing this?
>
>
> <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>cybs.qa.framework</groupId>
>  <version>2.0</version>
>  <artifactId>QA-Automation</artifactId>
>  <packaging>pom</packaging>
>  <modules>
>    <module>businessobjects</module>
>    <module>framework</module>
>                <module>utilities</module>
>                <module>uimodel</module>
>                <module>keywords</module>
>                <module>fixtures</module>
>                <module>unittests</module>
>                <module>tests</module>
>  </modules>
>
> <dependencies>
>            <dependency>
>                        <groupId>org.testng</groupId>
>                        <artifactId>testng</artifactId>
>                        <version>5.14</version>
>                        <scope>test</scope>
>            </dependency>
>  </dependencies>
>
>            <build>
>                        <pluginManagement>
>                                    <plugins>
>                                                <plugin>
>
>  <groupId>org.apache.maven.plugins</groupId>
>
>  <artifactId>maven-surefire-plugin</artifactId>
>
>  <version>2.6</version>
>                                                            <configuration>
>
>  <workingDirectory>${basedir}\Tests</workingDirectory>
>
>  <testClassesDirectory>target/classes</testClassesDirectory>
>
>  <suiteXmlFiles>
>
>        <suiteXmlFile>tests\genericTests.xml</suiteXmlFile>
>
>  </suiteXmlFiles>
>                                                            </configuration>
>                                                </plugin>
>                                    </plugins>
>                        </pluginManagement>
>            </build>
> </project>
> _________________________________________
> Ed Abshire
>