Skip to content

Commit

Permalink
FLUME-716: Add ability to exclude or include arbitrary tests to maven…
Browse files Browse the repository at this point in the history
… build
  • Loading branch information
Jonathan Hsieh committed Jul 22, 2011
1 parent 4d96f07 commit 19248fd
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
53 changes: 53 additions & 0 deletions DEVNOTES
Expand Up @@ -163,6 +163,59 @@ different directories and thus need to change the setting.
</settings>
----

==== Including or excluding specific sets of tests.

We've added hooks to the maven build that will enable you to exclude
or include specific tests on a test run. This is useful for excluding
flakey tests or making a build that focuses solely upon flakey tests.

To do this we created two variables:

# test.include.pattern
# test.exclude.pattern

These variables take regular expression patterns of the files to be
included or excluded.

For the next set of examples, let's say you have flakey test called
TestFlaky1 and TestFlaky2.

You can execute tests that skip TestFlaky1 and TestFlaky2 by using the
following command line:

----
mvn test -Dtest.exclude.pattern=**/TestFlaky*.java
----

Alternately, you could be more explicit

----
mvn test -Dtest.exclude.pattern=**/TestFlaky1.java,**/TestFlaky2.java
----

Conversely, you could execute only the flaky tests by using:

----
mvn test -Dtest.include.pattern=**/TestFlaky*.java
----

You can also have a combination of imports and exports. This runs
TestFlaky* but skips over TestFlaky2:

----
mvn test -Dtest.include.pattern=**/TestFlaky*.java -Dtest.exclude.pattern=**/TestFlaky2.java
----

NOTE: Both test.exclude.pattern and test.include.pattern get
overridden if the test parameter is used. Consider:

----
mvn test -Dtest.exclude.pattern=**/TestFlaky*.java -Dtest=TestFlaky1
---

In this case, TestFlaky1 will be run despite being in the
test.exclude.pattern.

=== Running the most recent build

To run the most recent build of Flume, first build the distribuion
Expand Down
11 changes: 11 additions & 0 deletions pom.xml
Expand Up @@ -15,6 +15,10 @@

<!-- Set default encoding to UTF-8 to remove maven complaints -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- defaults for flaky test and focused test exclusions -->
<test.exclude.pattern>$</test.exclude.pattern> <!-- junk pattern -->
<test.include.pattern>**/Test*.java</test.include.pattern>
</properties>

<profiles>
Expand Down Expand Up @@ -356,6 +360,13 @@
<forkMode>always</forkMode>
<forkedProcessTimeoutInSeconds>480</forkedProcessTimeoutInSeconds>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<includes>
<include>${test.include.pattern}</include>
</includes>
<excludes>
<exclude>**/*$*</exclude>
<exclude>${test.exclude.pattern}</exclude>
</excludes>
</configuration>
</plugin>

Expand Down

0 comments on commit 19248fd

Please sign in to comment.