You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Marcin Kwapisz <mk...@zsk.p.lodz.pl> on 2010/01/05 11:36:52 UTC

Surefire and testSourceDirectory

Hi,
can someone tell me what is the purpose of <testSourceDirectory> in configuration of the surefire plugin. I do not think this parameter work at all. There is project.build.testSourceDirectory and I use it to point at my filtered test source files. But this method is very inconvenient due to NetBeans IDE - there is no "Test Packages" in project tree then.

Is there another way to tell compiler where test sources are? I tried to set project.build.testSourceDirectory (outside pom.xml) in profiles.xml, but it doesn't work.

Thanks in advance
Regards
-- 
Marcin Kwapisz



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire and testSourceDirectory

Posted by Anders Hammar <an...@hammar.net>.
off topic:
If the testSourceDirectory param isn't set correctly, unit test source files
wouldn't be found and thus not run (as they cannot be compiled).

/Anders

On Tue, Jan 5, 2010 at 12:41, Marcin Kwapisz <mk...@zsk.p.lodz.pl> wrote:

> > Well, the purpose is what the docs says:
> > "The test source directory containing test class sources."
> > And it does work, otherwise no unit tests would work/run for any Maven
> > project. As a convention, this param is defined in the Maven super pom.
>
> [Marcin Kwapisz]
> Source files are not run. You mean <testClassesDirectory>. This property
> must be set to directory where compiled test classes are placed.
> <testSourceDirectory> can be set in surefire configuration to whatever
> directory, and tests work properly.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Surefire and testSourceDirectory

Posted by Marcin Kwapisz <mk...@zsk.p.lodz.pl>.
> Well, the purpose is what the docs says:
> "The test source directory containing test class sources."
> And it does work, otherwise no unit tests would work/run for any Maven
> project. As a convention, this param is defined in the Maven super pom.

[Marcin Kwapisz]
Source files are not run. You mean <testClassesDirectory>. This property must be set to directory where compiled test classes are placed. <testSourceDirectory> can be set in surefire configuration to whatever directory, and tests work properly.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire and testSourceDirectory

Posted by Anders Hammar <an...@hammar.net>.
Well, the purpose is what the docs says:
"The test source directory containing test class sources."
And it does work, otherwise no unit tests would work/run for any Maven
project. As a convention, this param is defined in the Maven super pom. Have
a look here:
http://maven.apache.org/pom.html#The_Super_POM

If you want to change this to some other directory and that causes problem
in your IDE, that's a question for that IDE's Maven integration feature.
It's not a Maven issue.
If you do want to change the value of the testSourceDirectory param, you
should do that in your project's pom. Do that in the same manner as it's
defined in the super pom (not by a 'project.build.testSourceDirectory'
property).

/Anders

On Tue, Jan 5, 2010 at 11:36, Marcin Kwapisz <mk...@zsk.p.lodz.pl> wrote:

> Hi,
> can someone tell me what is the purpose of <testSourceDirectory> in
> configuration of the surefire plugin. I do not think this parameter work at
> all. There is project.build.testSourceDirectory and I use it to point at my
> filtered test source files. But this method is very inconvenient due to
> NetBeans IDE - there is no "Test Packages" in project tree then.
>
> Is there another way to tell compiler where test sources are? I tried to
> set project.build.testSourceDirectory (outside pom.xml) in profiles.xml, but
> it doesn't work.
>
> Thanks in advance
> Regards
> --
> Marcin Kwapisz
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Surefire and testSourceDirectory

Posted by Marcin Kwapisz <mk...@zsk.p.lodz.pl>.
> This is simply not where testSourceDirectory goes in the pom. The
> Surefire plugin does not look for this value where you've put it,
> therefore it has no effect on your build which is correct.
[Marcin Kwapisz] 
Why? This is parameter for surefire with default value set to ${project.build.testSourceDirectory}. The documentation for the surefire plugin is very misleading, and I think testSourceDirectory should be removed from required parameters (if it is ignored). I can set other parameters like classesDirectory and testClassesDirectory in the surefire configuration and they work. The description of these two parameters is identical to testSourcesDirectory

Regards,
Marcin


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire and testSourceDirectory

Posted by Wayne Fay <wa...@gmail.com>.
>                <artifactId>maven-surefire-plugin</artifactId>
>                <configuration>
>                    <testSourceDirectory>src/test/whatever</testSourceDirectory>

This is simply not where testSourceDirectory goes in the pom. The
Surefire plugin does not look for this value where you've put it,
therefore it has no effect on your build which is correct.

Refer to the XSD [1] (search for testSourceDirectory) and the Surefire
plugin docs [2].

[1] http://maven.apache.org/xsd/maven-4.0.0.xsd
[2] http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#testSourceDirectory

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Surefire and testSourceDirectory

Posted by Marcin Kwapisz <mk...@zsk.p.lodz.pl>.
Sorry, attachments are not accepted. It is my pom.xml

<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>pl.zsk.samples</groupId>
    <artifactId>SurefireFiltering</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>SurefireFiltering</name>
    <url>http://maven.apache.org</url>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <!--<classesDirectory>${project.build.directory}/testclassesdir</classesDirectory>-->
                    <!--<testClassesDirectory>${project.build.directory}/filteredTestClasses</testClassesDirectory>-->
                    <testSourceDirectory>src/test/whatever</testSourceDirectory>
                </configuration>
            </plugin>

        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <filteredValue>Przefiltrowano</filteredValue>
    </properties>
</project>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Surefire and testSourceDirectory

Posted by Marcin Kwapisz <mk...@zsk.p.lodz.pl>.
> Usually i use the tag <testSourceDirectory> in order to indicate if
> tests are for integration
> (<testSourceDirectory>src/it</testSourceDirectory>) or for unit tests
> (<testSourceDirectory>src/test</testSourceDirectory>)
> I use 2 modules, one for unit tests and another for integration tests
[[Marcin Kwapisz]] 

The following configuration doesn't work, testSourceDirectory under surefire plugin configuration can be set to any directory:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <testSourceDirectory>${project.build.directory}/filteredTestSources</testSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
</build>

And that one of course works (I use it), and if there is no test sources, no test will be compiled and run:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.3</version>
            </plugin>
        </plugins>
       <testSourceDirectory>${project.build.directory}/filteredTestSources</testSourceDirectory>
</build>

I attached simple example to this email, but I do not know if the list server accept it

Regards
Marcin


Re: Surefire and testSourceDirectory

Posted by Roland Brassous <r....@akka.eu>.
Hi
Usually i use the tag <testSourceDirectory> in order to indicate if tests are for integration (<testSourceDirectory>src/it</testSourceDirectory>) or for unit tests  (<testSourceDirectory>src/test</testSourceDirectory>)
I use 2 modules, one for unit tests and another for integration tests

Roland



Marcin Kwapisz a écrit :
> Hi,
> can someone tell me what is the purpose of <testSourceDirectory> in configuration of the surefire plugin. I do not think this parameter work at all. There is project.build.testSourceDirectory and I use it to point at my filtered test source files. But this method is very inconvenient due to NetBeans IDE - there is no "Test Packages" in project tree then.
>
> Is there another way to tell compiler where test sources are? I tried to set project.build.testSourceDirectory (outside pom.xml) in profiles.xml, but it doesn't work.
>
> Thanks in advance
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org