Michal Kordas
Michal Kordas

Reputation: 10925

Maven Surefire Plugin "include" option for Groovy sources

I have Groovy project and I want to control by Surefire which tests to execute (sample repo).

Assuming I have test ExampleTest I can configure Surefire as follows:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19</version>
    <configuration>
        <includes>
            <include>**/ExampleTest.*</include>
        </includes>
    </configuration>
</plugin>

I can also use <include>ExampleTest.*</include> or <include>ExampleTest</include> and it works.

Unfortunately I cannot configure it as <include>ExampleTest.groovy</include>, but it works for <include>ExampleTest.java</include>!

Why it works like that? Is it a bug?

Upvotes: 4

Views: 1039

Answers (2)

Ashutosh Jindal
Ashutosh Jindal

Reputation: 18869

I would recommend using the regex support in the <include> patterns as documented here.

For example, to include the ExampleTest.groovy file:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19</version>
            <configuration>
                <includes>
                    <include>%regex[ExampleTest\.groovy]</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 1

Sandeep Poonia
Sandeep Poonia

Reputation: 2188

Yes we can say it's a bug. You can't use .groovy in inclusion list. But it will work if you use .*, .java or .class.

Upvotes: 3

Related Questions