Question

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?

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top