jbailie1991
jbailie1991

Reputation: 1345

PITest: Configuration isn't applied correctly

I have the following in my pom file:

pom.xml

<reporting>
    <plugins>
        <plugin>
            <groupId>org.pitest</groupId>
            <artifactId>pitest-maven</artifactId>
            <version>1.1.8</version>
            <configuration>
                <targetClasses>
                    <param>com.myService.utility.*</param>
                </targetClasses>
                <reportsDirectory>/my-service/target</reportsDirectory>
                <targetTests>
                    <param>com.myService.utility.util.*</param>
                </targetTests>
                <timeoutConstant>5000</timeoutConstant>
                <excludeClasses>
                    <param>com.myService.utility.EmailImpl.java</param>
                    <param>com.myService.utility.Email.java</param>
                    <param>com.myService.utility.ValidationUtil.java.java</param>
                </excludeClasses>
                <avoidCallsTo>
                    <avoidCallsTo>org.apache.log4j</avoidCallsTo>
                    <avoidCallsTo>org.slf4j</avoidCallsTo>
                    <avoidCallsTo>org.apache.commons.logging</avoidCallsTo>
                </avoidCallsTo>
            </configuration>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>report</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>

When I run the tests, the timeout doesn't seem to have changed from the default 3000, the classes in excludeClasses are still picked up, and its still complaining about configuration for log4j(althoguh it is log4j2 so this looks like my fault for not specifying). I can't find many examples in the PITest documentation or anywhere else, minus very simple examples using targetClasses and targetTests

EDIT: I tried changing the reporting tags to build tags and removed the reportSets section. There is still no change; the utility src package contains 6 classes, of which the 3 I've outlined in the pom should be excluded, and there are 3 test files in the test counterpart package. the reporter is still pulling in the classes to be excluded and showing as 0% line and mutation coverage. It is also complaining about log4j configs despite the avoidCallsTo values

Upvotes: 0

Views: 1900

Answers (1)

henry
henry

Reputation: 6096

The configuration needs to be provided under build/plugins, not reporting.

Unfortunately maven doesn't throw any error when it can't map XML to a plugin.

Included/excluded classes accepts globs against java packages - not source files so should look something like :-

<excludeClasses>
    <param>com.myService.utility.EmailImpl</param>
    <param>com.myService.utility.Email</param>
    <param>com.myService.utility.ValidationUtil</param>
</excludeClasses>

Upvotes: 2

Related Questions