pitest icon indicating copy to clipboard operation
pitest copied to clipboard

scm plugin is configured but scmMutationCoverage doesnt recognize modified files

Open rum517 opened this issue 5 years ago • 3 comments

Hello, First of all huge thanks for actively maintaining pitest. We use pitest a lot and rely on it for recognising gaps in unit testing (we use version 1.4.9). We are recently trying to set up scmMutationCoverage to reduce the mutation analysis time. Below is our template for scm plugin configuration:

  <scm>
  <connection>scm:git:${stash.http.url}/${project.artifactId}.git</connection>
  <url>scm:git:${stash.http.url}/${project.artifactId}.git</url>    
 <developerConnection>scm:git:${stash.ssh.url}/${project.artifactId}.git</developerConnection>
 <tag>HEAD</tag>
 </scm>

Ours is a multi module project. When I run a 'mvn org.pitest:pitest-maven:scmMutationCoverage' from within a module my expectation is that it will run mutation tests for locally modified files in that module but what I see is that no modified files are picked up by pitest and I have pasted the console output below.

INFO] --- pitest-maven:1.4.9:scmMutationCoverage (default-cli) @ project--- [INFO] Found plugin : Default csv report plugin [INFO] Found plugin : Default xml report plugin [INFO] Found plugin : Default html report plugin [INFO] Found plugin : Static initializer code detector plugin [INFO] Found plugin : Static initializer filter plugin [INFO] Found plugin : Excluded annotations plugin [INFO] Found plugin : Inlined finally block filter plugin [INFO] Found plugin : Try with resources filter [INFO] Found plugin : Implicit null check filter [INFO] Found plugin : For each loop filter [INFO] Found plugin : Logging calls filter [INFO] Found plugin : Infinite for loop filter [INFO] Found plugin : Long running iterator loop filter [INFO] Found plugin : For loop counter filter [INFO] Found plugin : Kotlin junk mutations filter [INFO] Found plugin : Max mutations per class limit [INFO] Found plugin : Equals shortcut equivalent mutant filter [INFO] Found plugin : Trivial return vals equivalence filter [INFO] Found plugin : Mutant export plugin [INFO] Found shared classpath plugin : Default mutation engine [INFO] Found shared classpath plugin : JUnit plugin [INFO] Found shared classpath plugin : TestNG plugin [INFO] Scm root dir is C:\project [INFO] Executing: cmd.exe /X /C "git rev-parse --show-toplevel" [INFO] Working directory: C:\project [INFO] Executing: cmd.exe /X /C "git status --porcelain ." [INFO] Working directory: C:\project [WARNING] Ignoring unrecognized line: ?? project/~/ [INFO] No modified files found - nothing to mutation test, analyseLastCommit=false


The above problem happens when I run from root of the module as well. Below are details of configuration of pitest:

<plugin>
               <groupId>org.pitest</groupId>
               <artifactId>pitest-maven</artifactId>
               <version>1.4.9</version>
               <configuration>
                   <failWhenNoMutations>false</failWhenNoMutations>
                   <targetClasses>
                       <param>project.*</param>
                   </targetClasses>
                   <targetTests>
                       <param>project.**.*Test</param>
                   </targetTests>
                   <environmentVariables>
                       <PLATFORM_NAME>Test</PLATFORM_NAME>
                   </environmentVariables>
                   <timeoutFactor>0.5</timeoutFactor>
                   <timeoutConstant>500</timeoutConstant>
               </configuration>
</plugin>

I have also tried with -DanalyseLastCommit, I get the same problem. I had 1 file that I modified and below is the output I get when I run git status on a terminal:

$>cmd.exe /X /C "git status --porcelain ." M ModifiedFilename.java

Please can you help. I am happy to provide more details. Thanks a lot!

rum517 avatar Sep 05 '19 18:09 rum517

Hi,

Is there a solution for above.

I have similar configuration and scmMutationCoverage goal is not picking the changes .

Maven command : mvn clean test org.pitest:pitest-maven:scmMutationCoverage -Dinclude=ADDED,MODIFIED -DdestinationBranch=origin/develop

As per documentation , it suggests to configure SCM Plugin , which is set in POM.XML, but changes in class (public), the diff is not calculated against the remote.

Plugin Version : 1.6.3

Thanks Milind

milindbangar79 avatar Aug 03 '21 10:08 milindbangar79

I'm afraid the scm plugin has not received much love for a few years now. I'll take a look at this when I finally get chance, but in the meantime you might be interested in looking at https://pitest.groupcdg.com.

If you're using git, this provides a much better experience.

hcoles avatar Aug 03 '21 10:08 hcoles

Hi @hcoles ,

Thanks for the response. I will try that plugin.

If you can help, can you share a sample POM for scmMutationCoverage goal, with SCM Maven Plugin.

Here is what I have and is not working :

<plugin>
                <groupId>org.pitest</groupId>
                <artifactId>pitest-maven</artifactId>
                <version>1.6.3</version>
                <configuration>
                    <timestampedReports>false</timestampedReports>
                    <verbose>true</verbose>
                    <analyseLastCommit>true</analyseLastCommit>
                    <verbose>true</verbose>
                    <outputFormats>
                        <outputFormat>XML</outputFormat>
                        <outputFormat>HTML</outputFormat>
                    </outputFormats>
                    <timeoutConstant>90000</timeoutConstant>
                    <timeoutFactor>1.5</timeoutFactor>
                    <mutators>
                        <mutator>STRONGER</mutator>
                    </mutators>
                    <excludedClasses>
                        <excludedClass>com.mycompany.rfi.library.aspect.*</excludedClass>
                        <excludedClass>com.mycompany.rfi.library.config.*</excludedClass>
                        <excludedClass>com.mycompany.rfi.library.external.integration.*</excludedClass>
                        <excludedClass>com.mycompany.rfi.library.model.*</excludedClass>
                    </excludedClasses>
                    <include>ADDED,MODIFIED</include>
                    <connectionType>connection</connectionType>
                    <originBranch>origin/feature/TRMP-1979</originBranch>
                    <destinationBranch>origin/develop</destinationBranch>
                </configuration>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>scmMutationCoverage</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-scm-plugin</artifactId>
                        <version>1.11.2</version>
                    </dependency>
                </dependencies>
            </plugin>

Getting the exception --

Error injecting: org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider
java.lang.NoClassDefFoundError: org/apache/maven/scm/command/untag/UntagScmResult

Thanks in advance.

Regards Milind

milindbangar79 avatar Aug 03 '21 12:08 milindbangar79