This repository has been archived by the owner on Mar 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,368 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
*.class | ||
# IntelliJ IDEA | ||
.idea/ | ||
*.iml | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
# Mac OS X | ||
.DS_Store | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
# Maven | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# idea-pitest | ||
IDEA Pitest plugin | ||
|
||
Pitest (aka PIT) is a state of the art mutation testing system for Java and the JVM. | ||
|
||
Read all about it at http://pitest.org | ||
|
||
The original Pitest logo was created by Ling Yeung. It is licensed under a [Creative Commons License](http://creativecommons.org/licenses/by-nc-sa/3.0/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>idea-pitest</artifactId> | ||
<groupId>me.artspb.idea.pitest</groupId> | ||
<version>1.1.3.0</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>idea-pitest-example</artifactId> | ||
<version>1.1.3.0</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
19 changes: 19 additions & 0 deletions
19
idea-pitest-example/src/main/java/me/artspb/pitest/example/SecondClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package me.artspb.pitest.example; | ||
|
||
/** | ||
* @author Artem Khvastunov <[email protected]> | ||
*/ | ||
public class SecondClass { | ||
|
||
public int uncoveredMethod() { | ||
int i = 42; | ||
return Math.abs(i); | ||
} | ||
|
||
public int partiallyCoveredMethod(int input) { | ||
if (input >= 0 || input % 2 == 0) { | ||
return 42; | ||
} | ||
return 0; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
idea-pitest-example/src/main/java/me/artspb/pitest/example/SimplePojo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package me.artspb.pitest.example; | ||
|
||
public class SimplePojo { | ||
|
||
private String field; | ||
|
||
public String getField() { | ||
return field; | ||
} | ||
|
||
public void setField(String field) { | ||
this.field = field; | ||
doSomething(); | ||
new SecondClass(); | ||
} | ||
|
||
private void doSomething() { | ||
this.field = "dleif"; | ||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
idea-pitest-example/src/test/java/me/artspb/pitest/example/SecondClassTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.artspb.pitest.example; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class SecondClassTest { | ||
|
||
private SecondClass secondClass; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
secondClass = new SecondClass(); | ||
} | ||
|
||
@Test | ||
public void testUncoveredMethod() throws Exception { | ||
secondClass.uncoveredMethod(); | ||
} | ||
|
||
@Test | ||
public void testPartiallyCoveredMethod() throws Exception { | ||
int output = secondClass.partiallyCoveredMethod(-2); | ||
assertEquals(output, 42); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
idea-pitest-example/src/test/java/me/artspb/pitest/example/SimplePojoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package me.artspb.pitest.example; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class SimplePojoTest { | ||
|
||
private SimplePojo pojo; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
pojo = new SimplePojo(); | ||
} | ||
|
||
@Test | ||
public void testGetField() throws Exception { | ||
pojo.getField(); | ||
} | ||
|
||
@Test | ||
public void testSetField() throws Exception { | ||
pojo.setField("field"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<idea-plugin version="2"> | ||
|
||
<id>me.artspb.idea.pitest.plugin</id> | ||
<name>Pitest</name> | ||
<version>1.1.3.0</version> | ||
<idea-version since-build="139"/> | ||
<vendor email="[email protected]" url="http://artspb.me/pitest">Artem Khvastunov</vendor> | ||
<description><![CDATA[ | ||
IntelliJ IDEA plugin which allows user to run Pitest and see results directly in the IDE.<br/> | ||
Pitest (aka PIT) is a state of the art mutation testing system for Java and the JVM. Read all about it at http://pitest.org. | ||
]]></description> | ||
<change-notes> | ||
<![CDATA[ | ||
version 1.1.3.0 | ||
<br/> | ||
<ul> | ||
<li>first release</li> | ||
</ul> | ||
]]> | ||
</change-notes> | ||
|
||
<depends>com.intellij.modules.java</depends> | ||
<depends>JUnit</depends> | ||
<depends>Coverage</depends> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<runConfigurationExtension implementation="me.artspb.idea.pitest.plugin.execution.PitestRunConfigurationExtension"/> | ||
<programRunner implementation="me.artspb.idea.pitest.plugin.runner.PitestProgramRunner"/> | ||
<executor implementation="me.artspb.idea.pitest.plugin.execution.PitestExecutor"/> | ||
<coverageRunner implementation="me.artspb.idea.pitest.plugin.coverage.PitestCoverageRunner"/> | ||
</extensions> | ||
|
||
<application-components> | ||
</application-components> | ||
|
||
<project-components> | ||
</project-components> | ||
|
||
<actions> | ||
</actions> | ||
|
||
</idea-plugin> |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
idea-pitest-plugin/src/me/artspb/idea/pitest/plugin/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package me.artspb.idea.pitest.plugin; | ||
|
||
/** | ||
* @author Artem Khvastunov <[email protected]> | ||
*/ | ||
final public class Constants { | ||
|
||
public static final String ANY_CLASS_PATTERN = "(*)"; | ||
public static final String ANY_IN_PACKAGE_PATTERN = ".*"; | ||
|
||
private Constants() { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
idea-pitest-plugin/src/me/artspb/idea/pitest/plugin/Icons.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package me.artspb.idea.pitest.plugin; | ||
|
||
import com.intellij.openapi.util.IconLoader; | ||
|
||
import javax.swing.*; | ||
|
||
/** | ||
* @author Artem Khvastunov <[email protected]> | ||
*/ | ||
public final class Icons { | ||
|
||
public static final Icon PITEST = IconLoader.getIcon("/pitest.png"); | ||
|
||
private Icons() { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
idea-pitest-plugin/src/me/artspb/idea/pitest/plugin/Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package me.artspb.idea.pitest.plugin; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* @author Artem Khvastunov <[email protected]> | ||
*/ | ||
public final class Utils { | ||
|
||
private Utils() { | ||
} | ||
|
||
public static String concatenatePath(String parent, String child) { | ||
return new File(parent, child).getPath(); | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
idea-pitest-plugin/src/me/artspb/idea/pitest/plugin/configuration/PitestConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package me.artspb.idea.pitest.plugin.configuration; | ||
|
||
import com.intellij.execution.configurations.RunConfigurationBase; | ||
import com.intellij.openapi.util.InvalidDataException; | ||
import com.intellij.openapi.util.JDOMExternalizable; | ||
import com.intellij.openapi.util.Key; | ||
import com.intellij.openapi.util.WriteExternalException; | ||
import me.artspb.idea.pitest.plugin.configuration.junit.JUnitConfigurationUtils; | ||
import org.jdom.Element; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* @author Artem Khvastunov <[email protected]> | ||
*/ | ||
public class PitestConfiguration implements JDOMExternalizable { | ||
|
||
public static final Key<PitestConfiguration> PITEST_KEY = Key.create("me.artspb.idea.pitest.plugin"); | ||
|
||
private static final String EDIT_MANUALLY = "editManually"; | ||
private static final String TARGET_TESTS = "targetTests"; | ||
private static final String TARGET_CLASSES = "targetClasses"; | ||
private static final String EXCLUDED_CLASSES = "excludedClasses"; | ||
private static final String REPORT_DIR = "reportDir"; | ||
private static final String SOURCE_DIRS = "sourceDirs"; | ||
|
||
private boolean editManually; | ||
private String targetTests; | ||
private String targetClasses; | ||
private String excludedClasses; | ||
private String reportDir; | ||
private String sourceDirs; | ||
|
||
public static PitestConfiguration getOrCreate(@NotNull RunConfigurationBase runConfiguration) { | ||
PitestConfiguration configuration = runConfiguration.getCopyableUserData(PITEST_KEY); | ||
if (configuration == null || !configuration.isEditManually()) { | ||
if (JUnitConfigurationUtils.supports(runConfiguration)) { | ||
configuration = JUnitConfigurationUtils.parse(runConfiguration); | ||
} | ||
runConfiguration.putCopyableUserData(PITEST_KEY, configuration); | ||
} | ||
return configuration; | ||
} | ||
|
||
@Override | ||
public void readExternal(Element element) throws InvalidDataException { | ||
setEditManually(Boolean.valueOf(element.getAttributeValue(EDIT_MANUALLY))); | ||
setTargetTests(element.getAttributeValue(TARGET_TESTS)); | ||
setTargetClasses(element.getAttributeValue(TARGET_CLASSES)); | ||
setExcludedClasses(element.getAttributeValue(EXCLUDED_CLASSES)); | ||
setReportDir(element.getAttributeValue(REPORT_DIR)); | ||
setSourceDirs(element.getAttributeValue(SOURCE_DIRS)); | ||
} | ||
|
||
@Override | ||
public void writeExternal(Element element) throws WriteExternalException { | ||
if (isEditManually()) { | ||
element.setAttribute(EDIT_MANUALLY, String.valueOf(true)); | ||
element.setAttribute(TARGET_TESTS, getTargetTests()); | ||
element.setAttribute(TARGET_CLASSES, getTargetClasses()); | ||
element.setAttribute(EXCLUDED_CLASSES, getExcludedClasses()); | ||
element.setAttribute(REPORT_DIR, getReportDir()); | ||
element.setAttribute(SOURCE_DIRS, getSourceDirs()); | ||
} | ||
} | ||
|
||
public boolean isEditManually() { | ||
return editManually; | ||
} | ||
|
||
public void setEditManually(boolean editManually) { | ||
this.editManually = editManually; | ||
} | ||
|
||
public String getTargetTests() { | ||
return targetTests; | ||
} | ||
|
||
public void setTargetTests(String targetTests) { | ||
this.targetTests = targetTests; | ||
} | ||
|
||
public String getTargetClasses() { | ||
return targetClasses; | ||
} | ||
|
||
public void setTargetClasses(String targetClasses) { | ||
this.targetClasses = targetClasses; | ||
} | ||
|
||
public String getExcludedClasses() { | ||
return excludedClasses; | ||
} | ||
|
||
public void setExcludedClasses(String excludedClasses) { | ||
this.excludedClasses = excludedClasses; | ||
} | ||
|
||
public String getReportDir() { | ||
return reportDir; | ||
} | ||
|
||
public void setReportDir(String reportDir) { | ||
this.reportDir = reportDir; | ||
} | ||
|
||
public String getSourceDirs() { | ||
return sourceDirs; | ||
} | ||
|
||
public void setSourceDirs(String sourceDirs) { | ||
this.sourceDirs = sourceDirs; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...t-plugin/src/me/artspb/idea/pitest/plugin/configuration/junit/ClassBasedConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.artspb.idea.pitest.plugin.configuration.junit; | ||
|
||
import com.intellij.execution.junit.JUnitConfiguration; | ||
import com.intellij.psi.util.ClassUtil; | ||
import me.artspb.idea.pitest.plugin.configuration.PitestConfiguration; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
import static me.artspb.idea.pitest.plugin.Constants.ANY_IN_PACKAGE_PATTERN; | ||
|
||
/** | ||
* @author Artem Khvastunov <[email protected]> | ||
*/ | ||
class ClassBasedConfigurator extends Configurator { | ||
|
||
@Override | ||
public void configure(JUnitConfiguration jUnitConfiguration, PitestConfiguration configuration) { | ||
JUnitConfiguration.Data data = jUnitConfiguration.getPersistentData(); | ||
String targetTests = data.getMainClassName(); | ||
String targetClasses; | ||
if (StringUtils.endsWith(targetTests, "Test")) { | ||
targetClasses = targetTests.substring(0, targetTests.lastIndexOf("Test")); | ||
} else { | ||
targetClasses = ClassUtil.extractPackageName(targetTests) + ANY_IN_PACKAGE_PATTERN; | ||
} | ||
configure(configuration, targetTests, targetClasses); | ||
} | ||
} |
Oops, something went wrong.