Pitclipse Failing to mutate code

636 views
Skip to first unread message

Walter Schilling

unread,
May 7, 2014, 6:32:06 PM5/7/14
to pitu...@googlegroups.com
I have a very trivial example I am using o check the setup of PitClipse on my machine using Eclipse Kepler.  (I have tried 3 different machines, running 64 bit and 32 bit Java, and I have checked against testNG and JUnit 4)

I have installed PitClipse on all machines, and my project has used PitClipse before.  When I select the test cases by right clicking and select run as PitTYest, the tool is starting up, but I am getting the following log:
Connecting to: localhost/127.0.0.1:53652
Connected
Received request: PitRequest [options=PitOptions [reportDir=D:\Dropbox\ClassPreps\Spring20132014\se2832\Labs\.metadata\.plugins\org.pitest.pitclipse.core\html_results, classUnderTest=CalculatorTest, classesToMutate=[.*], sourceDirs=[D:\Dropbox\ClassPreps\Spring20132014\se2832\Labs\Lab8MutationTesting2014\src], packages=[], threads=4, historyLocation=null, excludedClasses=[], excludedMethods=[], avoidCallsTo=[java.util.logging, org.apache.log4j, org.slf4j, org.apache.commons.logging]], projects=[Lab8MutationTesting2014]]
5:28:08 PM PIT >> FINE : Running report with ReportOptions [config=org.pitest.mutationtest.config.CompoundConfiguration@2376170d, targetClasses=[^\..*$], excludedMethods=[], excludedClasses=[], codePaths=[], reportDir=D:\Dropbox\ClassPreps\Spring20132014\se2832\Labs\.metadata\.plugins\org.pitest.pitclipse.core\html_results, historyInputLocation=null, historyOutputLocation=null, sourceDirs=[D:\Dropbox\ClassPreps\Spring20132014\se2832\Labs\Lab8MutationTesting2014\src], classPathElements=[D:\Dropbox\ClassPreps\Spring20132014\se2832\Labs\Lab8MutationTesting2014\bin, C:\eclipse64\plugins\org.junit_4.11.0.v201303080030\junit.jar, C:\eclipse64\plugins\org.hamcrest.core_1.3.0.v201303031735.jar, C:\eclipse64\plugins\org.pitest.command-line-osgi_0.33.0.jar, C:\eclipse64\plugins\org.pitest.osgi_0.33.0.jar, C:\eclipse64\plugins\org.pitest.pitclipse-pitrunner_0.33.2.201404202230.jar, C:\eclipse64\plugins\org.pitest.guava-shade-osgi_16.0.1.jar, C:\eclipse64\configuration\org.eclipse.osgi\bundles\474\1\.cp\lib\jsr305-2.0.0.jar], mutators=[], dependencyAnalysisMaxDistance=-1, mutateStaticInitializers=false, jvmArgs=[], numberOfThreads=4, timeoutFactor=1.25, timeoutConstant=4000, targetTests=[^CalculatorTest$], loggingClasses=[java.util.logging, org.apache.log4j, org.slf4j, org.apache.commons.logging], maxMutationsPerClass=0, verbose=true, failWhenNoMutations=false, outputs=[HTML, PITCLIPSE_MUTATIONS], groupConfig=TestGroupConfig [excludedGroups=[], includedGroups=[]], mutationUnitSize=0, shouldCreateTimestampedReports=true, detectInlinedCode=false, exportLineCoverage=false, mutationThreshold=0, coverageThreshold=0, mutationEngine=gregor, javaExecutable=null]
5:28:08 PM PIT >> FINE : System class path is D:\Dropbox\ClassPreps\Spring20132014\se2832\Labs\Lab8MutationTesting2014\bin;C:\eclipse64\plugins\org.junit_4.11.0.v201303080030\junit.jar;C:\eclipse64\plugins\org.hamcrest.core_1.3.0.v201303031735.jar;C:\eclipse64\plugins\org.pitest.command-line-osgi_0.33.0.jar;C:\eclipse64\plugins\org.pitest.osgi_0.33.0.jar;C:\eclipse64\plugins\org.pitest.pitclipse-pitrunner_0.33.2.201404202230.jar;C:\eclipse64\plugins\org.pitest.guava-shade-osgi_16.0.1.jar;C:\eclipse64\configuration\org.eclipse.osgi\bundles\474\1\.cp\lib\jsr305-2.0.0.jar
5:28:08 PM PIT >> FINE : Maximum available memory is 1806 mb
5:28:08 PM PIT >> FINE : using port 8092
5:28:08 PM PIT >> FINE : SLAVE : Installing PIT agent

5:28:08 PM PIT >> INFO : Sending 1 test classes to slave
5:28:08 PM PIT >> INFO : Sent tests to slave
5:28:09 PM PIT >> INFO : SLAVE : 5:28:08 PM PIT >> FINE : Expecting 1 tests classes from parent
5:28:08 PM PIT >> FINE : Tests classes received

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> INFO : Found  3 tests

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> INFO : Dependency analysis reduced number of potential tests by 0

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> INFO : 3 tests received

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> FINE : Running 3 units

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> FINE : Gathering coverage for test Description [testClass=CalculatorTest, name=testMultiply(CalculatorTest)]

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> FINE : Gathering coverage for test Description [testClass=CalculatorTest, name=testSimpleAdd(CalculatorTest)]

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> FINE : Gathering coverage for test Description [testClass=CalculatorTest, name=testSubtract(CalculatorTest)]

5:28:09 PM PIT >> INFO : SLAVE : 5:28:09 PM PIT >> FINE : Finished

5:28:09 PM PIT >> INFO : Calculated coverage in 0 seconds.
5:28:09 PM PIT >> FINE : Used memory after coverage calculation 15 mb
5:28:09 PM PIT >> FINE : Free Memory after coverage calculation 105 mb
5:28:09 PM PIT >> INFO : Created  0 mutation test units
5:28:09 PM PIT >> WARNING : No mutations found. This probably means there is an issue with either the supplied classpath or filters.
See http://pitest.org for more details.
5:28:09 PM PIT >> FINE : Used memory before analysis start 17 mb
5:28:09 PM PIT >> FINE : Free Memory before analysis start 103 mb
5:28:09 PM PIT >> FINE : Running 0 units
5:28:09 PM PIT >> FINE : Finished
5:28:09 PM PIT >> INFO : Completed in 0 seconds
================================================================================

However, in the past, this exact code has mutated very well with PitClipse on different computers.  What aspect of configuration might be wrong that would prevent this eclipse plugin from working?  I'm attached the code and test cases below as well:

Code:
/**
 * The following class holds calculator operations.
 * @author schilling
 *
 */
public class CalculatorExample {
/**
* This method will add two integers and provide the result as a return value.
* @param a This is the first addend.
* @param b This is the second addend.
* @return The return value is the sum of the two numbers.
*/
public int add(int a, int b) {
return a + b;
}

/**
* This method will add two integers and provide the result as a return value.
* @param a This is the first parameter.
* @param b This is the second parameter.
* @return The return value is the difference of the two numbers.
*/
public int subtract(int a, int b) {
return a - b;
}

public int multiply(int a, int b) {
return a * b;
}

public int divide(int a, int b) {
return a / b;
}
}

Test cases:
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * This class will verify the operation of the simple calculator class.
 * @author schilling
 *
 */
public class CalculatorTest {

private CalculatorExample c;
/**
* This method will simply instantiate a new instance of the Calculator class so that it is clean each time a test case executes.
*/
@Before
public void setup()
{
c=new CalculatorExample();
}
@Test
/**
* This method ensures that the addition operation works properly.
*/
public void testSimpleAdd() {
assertEquals(c.add(1, 1), 2);
}
@Test
/**
* This method will test that simple subtraction works.
*/
public void testSubtract() {
assertEquals(c.subtract(0, 0), 0);
assertEquals(c.subtract(5, 4), 1);
}
@Test
/**
* The following is a basic test of multiplication, making certain two multiplies work properly.
*/
public void testMultiply()
{
assertEquals(c.multiply(0, 0),0);
//assertEquals(c.multiply(1, 1),1);
}
}


Walter Schilling

unread,
May 7, 2014, 7:07:03 PM5/7/14
to pitu...@googlegroups.com
As a follow on, I just installed IntelliJ on one of those machines, and I am receiving the following:

"C:\Program Files\Java\jdk1.7.0_25\bin\java" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_25\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext\zipfs.jar;D:\MyDocs\IdeaProjects\untitled1\out\production\untitled1;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.2\lib\junit-4.11.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.2\lib\hamcrest-core-1.3.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.2\lib\hamcrest-library-1.3.jar;D:\MyDocs\.IntelliJIdea13\config\plugins\pit-idea-plugin\lib\pitest-0.32.jar;D:\MyDocs\.IntelliJIdea13\config\plugins\pit-idea-plugin\lib\pitest-command-line-0.32.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.pitest.mutationtest.commandline.MutationCoverageReport --reportDir D:/MyDocs/IdeaProjects/untitled1/report --sourceDirs D:/MyDocs/IdeaProjects/untitled1/src --targetClasses "" --outputFormats XML,HTML
6:04:47 PM PIT >> INFO : Verbose logging is disabled. If you encounter an problem please enable it before reporting an issue.
6:04:47 PM PIT >> INFO : Sending 0 test classes to slave
6:04:47 PM PIT >> INFO : Sent tests to slave
6:04:47 PM PIT >> INFO : Calculated coverage in 0 seconds.
6:04:47 PM PIT >> INFO : Created  0 mutation test units
Exception in thread "main" org.pitest.help.PitHelpError: No mutations found. This probably means there is an issue with either the supplied classpath or filters.
See http://pitest.org for more details.
at org.pitest.mutationtest.tooling.MutationCoverage.checkMutationsFound(MutationCoverage.java:272)
at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:144)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:100)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:42)
at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:69)
at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

Process finished with exit code 1
Open report in browser

It clearly seems like config, but I am at a loss as to what the problem is.

Jarkko Rantavuori

unread,
May 8, 2014, 1:17:24 AM5/8/14
to pitu...@googlegroups.com
At least for IntelliJ IDEA, the problem seems clear, this one:

 --targetClasses "" 

You'd need to define your target classes.

I don't know about the Eclipse problem though.

-Jarkko


--
You received this message because you are subscribed to the Google Groups "PIT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pitusers+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Walter Schilling

unread,
May 8, 2014, 10:58:45 PM5/8/14
to pitu...@googlegroups.com
In case anyone is interested, I discovered the problem, and it impacts both IntelliJ and Eclipse.  Basically, I had my code in the default package as opposed to being in a deeper package.  With previous versions of code (i.e. last year) this worked fine, but for some reason, it doesn't work with the newest version.  Yes, I know it's bad practice not to have code in packages; this was a 2 class program I used to demonstrate mutation testing to students, so I hadn't gone to too much in the way of extremes.


On Wednesday, May 7, 2014 5:32:06 PM UTC-5, Walter Schilling wrote:

Henry Coles

unread,
May 9, 2014, 4:20:36 AM5/9/14
to pitu...@googlegroups.com
On 9 May 2014 03:58, Walter Schilling <schi...@msoe.edu> wrote:
In case anyone is interested, I discovered the problem, and it impacts both IntelliJ and Eclipse.  Basically, I had my code in the default package as opposed to being in a deeper package.  With previous versions of code (i.e. last year) this worked fine, but for some reason, it doesn't work with the newest version.  Yes, I know it's bad practice not to have code in packages; this was a 2 class program I used to demonstrate mutation testing to students, so I hadn't gone to too much in the way of extremes.


Thanks for reporting back.

I'm not entirely sure if pitest itself (without pitclipse) supports mutating classes in the default package - it would be difficult to set the filters up to mutate the intended code without also mutating other things running in the jvm. The only way it could work would be to list each file to be mutated explicitly.

Henry

Walter Schilling

unread,
May 9, 2014, 11:24:54 PM5/9/14
to pitu...@googlegroups.com, henry...@googlemail.com
I could see it being difficult.  The funny thing is the version that was "current" about a year ago seemed to do it without problems.  (That's the problem of teaching classes...  You often use a tool once or twice a year, and it almost always is a new version.)  That being said, not having the packages is a bad example for the students anyways.  Plus, for a few that had their code in the default package, it was a great teaching point as to why one should not do that.

Walt

Phil Glover

unread,
May 13, 2014, 3:53:39 AM5/13/14
to pitu...@googlegroups.com, henry...@googlemail.com
Hi Walt,

Yes, Pitclipse used to work fine with default classes.  I'll investigate this, knock up a test case and get back to you.


Cheers,
Phil

Phil Glover

unread,
Aug 28, 2014, 6:03:06 PM8/28/14
to pitu...@googlegroups.com
It turned out that mutating classes in the default package only worked when the workspace scope option was selected.  The latest version of Pitclipse now supports mutating classes for project level scope.
Reply all
Reply to author
Forward
0 new messages