Search code examples
code-coveragemutationpitest

PIT testing - need to exclude certain packages from the report


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?


Solution

  • 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.*