Exclude packages from TestNG
Asked Answered
R

1

9

Consider the following TestNG configuration which runs all tests in the com.example.functional.* pacakge:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Functional1" verbose="1" >
  <test name="FunctionalTest"   >
    <packages>
      <package name="com.example.functional.*">
      </package>
    </packages>
  </test>
</suite>

In order to split the test job, some exclusion rules were added:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Functional1" verbose="1" >
  <test name="FunctionalTest"   >
    <packages>
      <package name="com.example.functional.*">
            <exclude name="com.example.functional.services.courier.*"></exclude>
            <exclude name="com.example.functional.optimization.*"></exclude>
            <exclude name="com.example.functional.initialization"></exclude>
            <exclude name="com.example.functional.tasks"></exclude>
      </package>
    </packages>
  </test>
</suite>

The excluded package are still being executed - any idea why the exclusions are ignored?

Redhot answered 10/6, 2013 at 7:48 Comment(0)
E
10

The * is the problem. When excluding optimization.*, sub-packages of optimization are excluded, but optimization isn't.

Removing * from the exclude tags should do it:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Functional1" verbose="1" >
  <test name="FunctionalTest"   >
    <packages>
      <package name="com.example.functional.*">
            <exclude name="com.example.functional.services.courier"></exclude>
            <exclude name="com.example.functional.optimization"></exclude>
            <exclude name="com.example.functional.initialization"></exclude>
            <exclude name="com.example.functional.tasks"></exclude>
      </package>
    </packages>
  </test>
</suite>
Exiguous answered 10/6, 2013 at 11:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.