Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-131

Excluding tests with command line pattern

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0 (2.2 plugin)
    • 2.19
    • Maven Surefire Plugin
    • None
    • All environments running JUnit tests

    Description

      I'd like to be able to exclude certain tests from being run. An example of this could be a scenario where I'd like just the unit tests and not the integration tests to run. In our case, we name all integration test with the postfix "IntTest" instead of just "Test".

      This is now possible through configuring the plugin in the pom, however it is not possible to decide at the command line if I just like to run some tests and not all.

      Example of use with this implementation would be:
      mvn -Dexclude=*IntTest test
      which would run all tests - excluding those that ends with IntTest

      The amount of code needed for implementation is minimal. In SurefirePlugin.java:

      Just add a property - something like:

      /**

      • Specify this parameter to exclude test by their name. It follows
      • the same conventions as the <code>test</code> parameter.
      • @parameter expression="${exclude}"
      • */
        private String exclude;

      Add this code at line 527

      if ( this.exclude != null )

      { String exclude = "**/" + this.exclude + ".java"; excludes.add(exclude); getLog().debug( "Excluding test with pattern :" + exclude ); }

      ...and that's all.

      Attachments

        Issue Links

          Activity

            People

              tibordigana Tibor Digana
              johannesc Johannes Carlén
              Votes:
              8 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: