Java “马文最可怜的错误”;未找到前缀为';org.pitest';在当前项目和插件组中;
我需要使用PITest进行突变测试,但我很难通过Maven安装它,当我尝试运行PIT来执行突变和测试用例时,我在cmd中收到以下错误: “在当前项目中找不到前缀'org.pitest'的插件 以及在插件组中“Java “马文最可怜的错误”;未找到前缀为';org.pitest';在当前项目和插件组中;,java,maven,unit-testing,mutation-testing,pitest,Java,Maven,Unit Testing,Mutation Testing,Pitest,我需要使用PITest进行突变测试,但我很难通过Maven安装它,当我尝试运行PIT来执行突变和测试用例时,我在cmd中收到以下错误: “在当前项目中找不到前缀'org.pitest'的插件 以及在插件组中“ 有人能帮我解决这个问题吗 我的代码: package com.mateus; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Codigo { public boole
有人能帮我解决这个问题吗 我的代码:
package com.mateus;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Codigo {
public boolean verify(String word){
String regex = "^[a-zA-Z0-9_$]+$";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(word);
if(word.substring(0, 1).matches("[0-9]")){
return false;
}
return matcher.matches();
}
}
我的测试:
package com.mateus;
import static org.junit.Assert.*;
import org.junit.Test;
public class CodigoTest {
Codigo c = new Codigo();
@Test
public void test() {
assertEquals(true, c.verify("teste"));
}
@Test
public void test2() {
assertEquals(false, c.verify("1teste"));
}
@Test
public void test3() {
assertEquals(false, c.verify("tes@te"));
}
}
pom.xml:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mateus</groupId>
<artifactId>MavenMutacao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13-rc-1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.3</version>
<configuration>
<targetClasses>
<param>com.mateus*</param>
</targetClasses>
<targetTests>
<param>com.mateus*</param>
</targetTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
你必须像这样使用插件
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.10</version>
<configuration>
<targetClasses>
<param>com.mateus*</param>
</targetClasses>
<targetTests>
<param>com.mateus*</param>
</targetTests>
</configuration>
</plugin>
org.pitest
它也可以在maven central中找到,您可以查看此链接
我刚刚添加了依赖项,正如您所说,但是出现了相同的错误,顺便说一句,最后一个版本是1.4.10,我修复了它,但保持不变,我是否应该用当前的pom.xml编辑该问题,以便您可以看到它现在的状态?我真的需要尽快完成这项工作。请发布完整的pom.xml,这样我就可以在我这边尝试了。我刚刚更新了答案,您现在可以尝试了。更新版本1.4.10
以代替latest@DebadattaMishra使用maven插件作为依赖项是完全错误的。问题只是在命令行上错误地调用插件。你能告诉我在命令行上调用插件的正确方法是什么吗@khmarbaiseYou应该尝试使用mvn org.pitest:pitest-maven:mutationCoverage
。我还将使用最新版本的pitest maven插件…1.4.10…我写了一篇文章解释如何使用突变测试和PIT,这可能会对您有所帮助:如果您想了解如何使用maven多模块设置一个真正的实时项目,请举个例子:非常感谢,@khmarbaise!!它使用了这个命令。还有一个问题,我执行了它,一切都很好,但在我的“目标”文件夹中没有文件可以看到结果的图形界面,知道为什么吗@PEDRORIJO91是否应该有一个html文件,其中通常包含目标/站点中的结果?你看过了吗?
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.10</version>
<configuration>
<targetClasses>
<param>com.mateus*</param>
</targetClasses>
<targetTests>
<param>com.mateus*</param>
</targetTests>
</configuration>
</plugin>