Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 660
Michal Kordas Avatar asked Oct 21 '25 05:10

Michal Kordas


2 Answers

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.

like image 159
Sandeep Poonia Avatar answered Oct 23 '25 20:10

Sandeep Poonia


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>
like image 22
Ashutosh Jindal Avatar answered Oct 23 '25 21:10

Ashutosh Jindal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!