Title: TestNG 7.8.0 compilation error with Java 11 in IntelliJ IDEA 2018.3.6 (Community Edition)

已回答

Hello, JetBrains community,

I'm having an issue with running a Maven project in IntelliJ IDEA. I'm using TestNG version 7.8.0 and Selenium version 4.9.1 in my Maven dependencies. My system is using OpenJDK version "11.0.19" and Apache Maven 3.6.3. The operating system is Linux 5.19.0-46-generic.

When I try to compile my project in IntelliJ, I'm receiving the following error:

java: cannot access org.testng.annotations.Test
bad class file: /home/nxtwavetechhari/.m2/repository/org/testng/testng/7.8.0/testng-7.8.0.jar(org/testng/annotations/Test.class)
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

However, when I change the TestNG version to 7.4.0 in the pom.xml, the project runs successfully. It seems to be an issue with TestNG 7.8.0 and Java 11.

I've tried the following troubleshooting steps without success:

  • Specifying the source and target JDK version in the maven-compiler-plugin in the pom.xml
  • Invalidating IntelliJ IDEA caches and restarting
  • Reimporting Maven projects
  • Deleting the .idea directory and recreating it
  • Ensuring the correct JDK is selected in IntelliJ IDEA's settings
  • Updating IntelliJ IDEA to the latest version

Could someone please assist me with resolving this issue?

Thank you!

0
Does the same happen if you run the test suilte by mvn command lines?

Please also check if you have java 11 selected in the TestNG run configuration.
1

Hello,

Thank you for your quick response.

In response to your questions:

1. I have run the TestNG suite via Maven command lines using `mvn test`, and it runs successfully without any errors. The issue only seems to occur when running the tests using the Run button in IntelliJ IDEA.

2. I have confirmed that Java 11 is selected in the TestNG run configuration in IntelliJ IDEA. In `File -> Project Structure -> Project Settings -> Project`, under "Project SDK", Java 11 is selected. Additionally, my system's Java version and Maven's Java version are both set to 11.

Despite these configurations, the issue persists when TestNG version 7.8.0 is used and the tests are run using the Run button in IntelliJ IDEA. The issue does not occur with TestNG version 7.4.0 or when running the tests from the command line using Maven.

I'm looking forward to any further insights or suggestions you might have to resolve this issue.

Best regards,
Harikrishna Daggubati

0
Please try a newer version of the IDE than 2018 which supports running on JDK11+.
https://www.jetbrains.com/idea/download/other.html
0

请先登录再写评论。