pitest icon indicating copy to clipboard operation
pitest copied to clipboard

Java 14 with `--enable-preview` produce a `Ran 0 tests` result

Open EPadronU opened this issue 4 years ago • 2 comments

java -version

openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)

Important parts in POM:

  ...
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>14</maven.compiler.source>
    <maven.compiler.target>14</maven.compiler.target>
    <apache.commons.version>3.9</apache.commons.version>
    <assertj.version>3.15.0</assertj.version>
    <junit.version>5.6.1</junit.version>
    <log4j.version>2.13.1</log4j.version>
  </properties>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerArgs>
            <arg>--enable-preview</arg>
            <arg>-parameters</arg>
          </compilerArgs>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>--enable-preview</argLine>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.pitest</groupId>
        <artifactId>pitest-maven</artifactId>
        <dependencies>
          <dependency>
            <groupId>org.pitest</groupId>
            <artifactId>pitest-junit5-plugin</artifactId>
            <version>0.12</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    
    <pluginManagement>
        ...
        <plugin>
          <groupId>org.pitest</groupId>
          <artifactId>pitest-maven</artifactId>
          <version>1.5.1</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  ...

Without the --enable-preview flag everything runs as expected:

>> Generated 7 mutations Killed 6 (86%)
>> Ran 7 tests (1 tests per mutation)

Vs when it is set:

>> Generated 7 mutations Killed 0 (0%)
>> Ran 0 tests (0 tests per mutation)

EPadronU avatar Apr 22 '20 13:04 EPadronU

Added a PR. By using the newly documented example tests will be run successfully:

<configuration>
  <jvmArgs>
    <jvmArg>--enable-preview</jvmArg>
  </jvmArgs>
</configuration>

@EPadronU can you try the option please?

boris-github avatar Jul 29 '20 12:07 boris-github

Hi @boris-github,

I can confirm this works great. Thank you so much for taking the time to review this issue of mine. I feel ashamed for not having seen that error message in the logs, nor imagining PIT needs the flag as well.

Should I close the issue or that's something a core member should do?

EPadronU avatar Jul 29 '20 13:07 EPadronU