5

I am trying to generate a PIT Test Coverage Report and I need to exclude a certain package. These are the used configurations :

<plugin>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-maven</artifactId>
                        <version>1.3.0</version>
                        <configuration>
                            <targetClasses>
                                <param>test.presentation.*</param>
                                <param>test.service.impl.*</param>
                            </targetClasses>
                            <targetTests>
                                <param>test.App.ServletInitializerTest</param>
                                <param>test.presentation.AuthenticationControllerTest</param>
                                <param>test.service.impl.AuthenticationServiceImplTest</param>
                            </targetTests>
                            <excludedClasses>
                                <param>test.security.AuthenticationSecurityServiceImpl</param>
                                <param>test.security.TokenAuthenticationFilter</param>
                                <param>test.security.TokenInfo</param>
                                <param>test.security.TokenManagerImpl</param>
                            </excludedClasses>
                            <excludedTestClasses>
                                <param>test.security.AuthenticationSecurityServiceImplTest</param>
                            </excludedTestClasses>
                            <excludedMethods>
                            <param>test.service.impl.AuthenticationServiceImpl.userAuthentication</param>
                            </excludedMethods>
                            <avoidCallsTo>
                            <avoidCallsTo>test.service.impl.AuthenticationServiceImpl</avoidCallsTo>
                            <avoidCallsTo>test.security.*</avoidCallsTo>
                            </avoidCallsTo>
                        </configuration>
                    </plugin>

But my report still shows coverage for test.security.* package and test.service.impl.AuthenticationServiceImpl.userAuthentication method.

How can I skip this package and method in coverage report?

Madiha
  • 115
  • 2
  • 9

1 Answers1

7

You should be able to exclude test.security.* from mutation with

<excludedClasses>
 <param>test.security.*</param>
</excludedClasses>

The entry you have in avoidCallsTo will prevent mutation to line of code in other packages that make calls to methods in test.security.*

henry
  • 5,923
  • 29
  • 46
  • does that exclude all classes from `test.security` package recursively? I am looking for a way to exclude all classes under a package heirarchy - so that all classes under both `test.security` and `test.security.util` would be excluded. – Pat Oct 18 '18 at 04:14
  • 1
    @Pat yes, if you include the wildcard at the end it should exclude all sub packages. It's just a simple glob match on the name. – henry Oct 19 '18 at 10:01