4

i exclude all tests in plugin except my test suite:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.11</version>
    <configuration>
        <!--
        <testFailureIgnore>true</testFailureIgnore>
        <skipTests>true</skipTests>
        -->
        <parallel>both</parallel>
        <threadCount>10</threadCount>
        <forkMode>once</forkMode>
        <configuration>
            <excludes>
                <exclude>**/Test*.java</exclude>
                <exclude>**/*Test.java</exclude>
                <exclude>**/*TestCase.java</exclude>
            </excludes>
            <includes>
                <include>ru.csbi.registry.CategorizedTestsSuite.java</include>
            </includes>
        </configuration>
        <!--
       <configuration>
           <groups>ru.csbi.registry.IntegrationTestsNotRequiringContainerCategory</groups>
           <groups>ru.csbi.registry.UnitTestsCategory</groups>
       </configuration>
        -->
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit47</artifactId>
            <version>2.12</version>
        </dependency>
    </dependencies>
</plugin>

but all tests are executed.

Even if i delete my the only include in config it still runs all tests:

<configuration>
    <excludes>
        <exclude>**/Test*.java</exclude>
        <exclude>**/*Test.java</exclude>
        <exclude>**/*TestCase.java</exclude>
    </excludes>
    <!--
   <includes>
       <include>ru.csbi.registry.CategorizedTestsSuite.java</include>
   </includes>
    -->
</configuration>

Here is the logs:

------------------------------------------------------- T E S T S ------------------------------------------------------- Concurrency config is parallel='both',perCoreThreadCount=true, threadCount=10, useUnlimitedThreads=false

Running javalangtests.AnnotationTest

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.JdbcServiceTest

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.reflection.ClassServiceTest

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.reflection.FieldServiceTest

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Running ru.csbi.registry.services.reflection.hibernate.relation.RelationServiceTest

Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec

Effective pom:

  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
    <executions>
      <execution>
        <id>default-test</id>
        <phase>test</phase>
        <goals>
          <goal>test</goal>
        </goals>
        <configuration>
          <configuration>
            <includes>
              <include>ru.csbi.registry.CategorizedTestsSuite.java</include>
            </includes>
          </configuration>
        </configuration>
      </execution>
    </executions>
    <configuration>
      <configuration>
        <includes>
          <include>ru.csbi.registry.CategorizedTestsSuite.java</include>
        </includes>
      </configuration>
    </configuration>
  </plugin>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Vyacheslav
  • 3,134
  • 8
  • 28
  • 42
  • Are the tests all defined in your Suite ? Why are you using Suites anymore ? – khmarbaise Feb 27 '12 at 07:51
  • 1
    1) Try to remove `` section and add `ru/csbi/registry/CategorizedTestsSuite.java`. 2) Try to upgrade to 2.12. – Andrew Logvinov Feb 27 '12 at 07:52
  • Does your pom has a ``? Maybe there is a configuration for Surefire that is defined there. Run the command `mvn help:effective-pom -Doutput=full-pom.xml`, and check if everything is OK. – Romain Linsolas Feb 27 '12 at 08:03
  • upgraded to 2.12. removed excludes: here is effective pom, no parent pom specified in config. Still runs all other tests. – Vyacheslav Feb 27 '12 at 08:24
  • I think you incorrectly specify ``. See my comment above. – Andrew Logvinov Feb 27 '12 at 08:30
  • no i wanted to exclude all test during run. Even i exclude all tests they are executed. Suite does not contains uncategorized test from classpath, for example JasperReportsServiceTest which is run all the time. – Vyacheslav Feb 27 '12 at 08:36
  • @khmarbaise i'm using suite to run all categorized tests in ide. Not all tests are categorized yet in my project. – Vyacheslav Feb 27 '12 at 08:50
  • Hm.What about excluding the suite and let surefire plugin run all the other tests ? – khmarbaise Feb 27 '12 at 08:56
  • I'm not quite understand what you mean. Issue is solved already. i needed to run just that test suite. It is already created and i don't need to specify categories in pom at the moment. The issue was that all excludes does not work at all. – Vyacheslav Feb 27 '12 at 09:05

1 Answers1

5

You need to remove configuration block from configuration block.

Like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.11</version>
    <configuration>
        <!--
        <testFailureIgnore>true</testFailureIgnore>
        <skipTests>true</skipTests>
        -->
        <parallel>both</parallel>
        <threadCount>10</threadCount>
        <forkMode>once</forkMode>
        <excludes>
            <exclude>**/Test*.java</exclude>
            <exclude>**/*Test.java</exclude>
            <exclude>**/*TestCase.java</exclude>
        </excludes>
        <includes>
            <include>ru.csbi.registry.CategorizedTestsSuite.java</include>
        </includes>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit47</artifactId>
            <version>2.12</version>
        </dependency>
    </dependencies>
</plugin>

Nested configuration element makes no sense. As well as package name in your include (ru.csbi.registry.CategorizedTestsSuite.java).

weekens
  • 8,064
  • 6
  • 45
  • 62
  • Thanks. It is strange that it passes xml validation in eclipse. – Vyacheslav Feb 27 '12 at 08:40
  • 1
    @Vyacheslav Plugin configuration doesn't have strict grammar and allows arbitrary elements. Including another configuration element :) – weekens Feb 27 '12 at 08:42
  • 1
    +1 - Had the same error but was using the configuration tag inside an execution which seemed to be fine (eclipse autocomplete suggested it) but did not work. Moving it to be a child of the plugin tag made it work (similar to this solution) – codewing May 15 '17 at 07:15