首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PIT >>信息: MINION :下午3:10:40,>>信息:找到0项测试

PIT >>信息: MINION :下午3:10:40,>>信息:找到0项测试
EN

Stack Overflow用户
提问于 2021-03-21 07:20:35
回答 2查看 691关注 0票数 0

我正在尝试将坑测试集成到我的项目中。

这是我的pom.xml文件。

pom.xml

代码语言:javascript
复制
<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>com2.com3.app</groupId>
  <artifactId>team-10</artifactId>
  <version>1.0-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <directory>target</directory>
    <testSourceDirectory>test</testSourceDirectory>
    <testOutputDirectory>target/classes</testOutputDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>11</source>
          <target>11</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <dependencies>
          <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>1.0.0</version>
          </dependency>
          <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.0.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.pitest</groupId>
        <artifactId>pitest-maven</artifactId>
        <version>1.4.6</version>
        <configuration>
          <targetClasses>
            <param>com1.com2.com3.impl.app.LsApplication</param>
          </targetClasses>
          <targetTests>
            <param>com1.com2.com3.impl.app.LsApplicationTest</param>
          </targetTests>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <myTestSourceDirectory>test</myTestSourceDirectory>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.3</version>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.7.0</version>
    </dependency>
    <dependency>
      <groupId>org.pitest</groupId>
      <artifactId>pitest-junit5-plugin</artifactId>
      <version>0.7</version>
    </dependency>
  </dependencies>
</project>

我的项目正在使用Maven,但它目前没有遵循默认结构。源代码存储在src/com1.com2.com3,而测试代码存储在test/com1.com2.com3

我运行了mvn clean install,它运行了我使用创建的所有测试文件,但是所有这些文件都会导致失败。

然后我运行mvn org.pitest:pitest-maven:mutationCoverage,它生成以下输出,它传入两个类文件,一个是源,一个是类文件。然而,没有检测到任何测试。这些测试在JUnit下运行的很好,我在这里错过了什么呢?如果需要更多的信息,请告诉我。

代码语言:javascript
复制
[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] Adding org.pitest:pitest to SUT classpath
[INFO] Mutating from /Users/prashin/target/classes
3:10:40 pm PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue.
3:10:40 pm PIT >> INFO : Sending 2 test classes to minion
3:10:40 pm PIT >> INFO : Sent tests to minion
3:10:40 pm PIT >> INFO : MINION : 3:10:40 pm PIT >> INFO : Checking environment

3:10:40 pm PIT >> INFO : MINION : 3:10:40 pm PIT >> INFO : Found  0 tests

3:10:40 pm PIT >> INFO : MINION : 3:10:40 pm PIT >> INFO : Dependency analysis reduced number of potential tests by 0

3:10:40 pm PIT >> INFO : MINION : 3:10:40 pm PIT >> INFO : 0 tests received

3:10:40 pm PIT >> INFO : Calculated coverage in 0 seconds.
3:10:40 pm PIT >> INFO : Created  1 mutation test units                                                                                                                    /3:10:41 pm PIT >> INFO : Completed in 1 seconds
================================================================================
- Mutators
================================================================================
> org.pitest.mutationtest.engine.gregor.mutators.ConditionalsBoundaryMutator
>> Generated 8 Killed 0 (0%)
> KILLED 0 SURVIVED 0 TIMED_OUT 0 NON_VIABLE 0 
> MEMORY_ERROR 0 NOT_STARTED 0 STARTED 0 RUN_ERROR 0 
> NO_COVERAGE 8 
--------------------------------------------------------------------------------
> org.pitest.mutationtest.engine.gregor.mutators.IncrementsMutator
>> Generated 3 Killed 0 (0%)
> KILLED 0 SURVIVED 0 TIMED_OUT 0 NON_VIABLE 0 
> MEMORY_ERROR 0 NOT_STARTED 0 STARTED 0 RUN_ERROR 0 
> NO_COVERAGE 3 
--------------------------------------------------------------------------------
> org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator
>> Generated 10 Killed 0 (0%)
> KILLED 0 SURVIVED 0 TIMED_OUT 0 NON_VIABLE 0 
> MEMORY_ERROR 0 NOT_STARTED 0 STARTED 0 RUN_ERROR 0 
> NO_COVERAGE 10 
--------------------------------------------------------------------------------
> org.pitest.mutationtest.engine.gregor.mutators.ReturnValsMutator
>> Generated 25 Killed 0 (0%)
> KILLED 0 SURVIVED 0 TIMED_OUT 0 NON_VIABLE 0 
> MEMORY_ERROR 0 NOT_STARTED 0 STARTED 0 RUN_ERROR 0 
> NO_COVERAGE 25 
--------------------------------------------------------------------------------
> org.pitest.mutationtest.engine.gregor.mutators.MathMutator
>> Generated 5 Killed 0 (0%)
> KILLED 0 SURVIVED 0 TIMED_OUT 0 NON_VIABLE 0 
> MEMORY_ERROR 0 NOT_STARTED 0 STARTED 0 RUN_ERROR 0 
> NO_COVERAGE 5 
--------------------------------------------------------------------------------
> org.pitest.mutationtest.engine.gregor.mutators.NegateConditionalsMutator
>> Generated 51 Killed 0 (0%)
> KILLED 0 SURVIVED 0 TIMED_OUT 0 NON_VIABLE 0 
> MEMORY_ERROR 0 NOT_STARTED 0 STARTED 0 RUN_ERROR 0 
> NO_COVERAGE 51 
--------------------------------------------------------------------------------
================================================================================
- Timings
================================================================================
> scan classpath : < 1 second
> coverage and dependency analysis : < 1 second
> build mutation tests : < 1 second
> run mutation analysis : < 1 second
--------------------------------------------------------------------------------
> Total  : < 1 second
--------------------------------------------------------------------------------
================================================================================
- Statistics
================================================================================
>> Generated 102 mutations Killed 0 (0%)
>> Ran 0 tests (0 tests per mutation)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.249 s
[INFO] Finished at: 2021-03-21T15:10:41+08:00
[INFO] ------------------------------------------------------------------------
EN

回答 2

Stack Overflow用户

发布于 2021-03-21 08:28:03

首先,为什么要更改缺省值,如源代码目录等,遵循惯例就更容易了。因此,删除以下内容:

代码语言:javascript
复制
<sourceDirectory>src</sourceDirectory>
<directory>target</directory>
<testSourceDirectory>test</testSourceDirectory>
<testOutputDirectory>target/classes</testOutputDirectory>

并相应地将项目的目录布局更改为maven约定。

其次,如果你使用junit木星,你必须至少使用更可靠的2.22.2更好的最新版本(3.0.0-M5)。

此外,你使用junit木星5.0.0,它大约有3年历史.您应该转到最近的(5.7.1),您正在手动定义junit-platform-surefire-provider,这不应该再做了(很长时间).

您使用的最坏版本是非常旧的(最近的版本为1.6.4),最后应该将pitest-junit5-plugin定义为在此期间版本为0.14的最坏版本maven-plugin的依赖关系。

您可以查看这样一个示例项目:https://github.com/khmarbaise/kata-fraction/blob/master/pom.xml

此外,您还混合了不同的概念:

maven编译器插件的配置:

代码语言:javascript
复制
<configuration>
  <source>11</source>
  <target>11</target>
</configuration>

和以财产为基础的办法:

代码语言:javascript
复制
<properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
  <myTestSourceDirectory>test</myTestSourceDirectory>
</properties>

最后一个问题是: JDK 8还是JDK11?

如果您使用JDK11,您应该只设置这些选项,而不是同时设置,第二,您可以检查使用--release 11 via (基于<maven.compiler.release>11</maven.compiler.release>属性)是否更好。

最后,我看到您有一个依赖关系:

代码语言:javascript
复制
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.12</version>
</dependency>

这是否意味着您正在使用基于JUnit 4的单元测试?如果是这样的话,您必须添加JUnit -老式引擎,以便您可以运行您的JUnit 4基础测试通过JUnit木星。我强烈建议将所有基于JUnit 4的测试迁移到JUnit木星,然后删除junit 4依赖项。

票数 1
EN

Stack Overflow用户

发布于 2021-03-21 11:38:16

我们有非常详细的文件。它包含示例和指向我们在GitHub上的集成测试的链接。请在浏览器https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html中打开这个链接,如果有什么不清楚,请随时提问。我们热衷于回答这些问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66729779

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档