Error: org.testng.TestNGException: Cannot find class in classpath: EmpClass

前端 未结 30 1093
礼貌的吻别
礼貌的吻别 2020-12-09 08:17

When i\'m trying to run the test suite, am getting this exception. We are using maven project here and i am done with refreshing, cleaning, reinstalling testNG and then impo

相关标签:
30条回答
  • 2020-12-09 09:09

    I also had this issue. I'm using IntelliJ IDEA. I was using src/main/java for configuration files and src/test/java for test files.
    Because of this testNG couldn't find the class path. To prevent getting that error need to move all the files from src/main/java to src/test/java or vice versa.

    0 讨论(0)
  • 2020-12-09 09:10

    I faced the similar issue on importing maven with testng project. This was solved by converting again into TestNg project by

    right click on eclipse project > TestNG > Convert to TestNG

    and replacing the existing testng.xml file with the newly created. Clean and update the maven project with mvn install

    Note: take backup of your testng.xml

    0 讨论(0)
  • 2020-12-09 09:10

    Let me share what worked for me:

    1. When we do "mvn clean" - we are cleaning old compiled classes please lgo to ocation "your project directroy -> target " you will find this folder is getting cleaned because that's where MVN places it's compiled artifacts

    2. Since it's already a MAVEN project then go to your project folder and open in command prompt. And issue "mvn clean" and then "mvn test" -> "mvn test" command will place all the compiled files under proper folders and then you can run your tests through TestNG or MAVEN itself.

    3. Make sure you set up "M2_HOME" or "MAVEN_HOME" to your env path , sometime "MAVEN_HOME" doesn't work so add "M2_HOME" as well (google it for this set up)

    Above suggestions worked for me so I wanted to share, good luck

    0 讨论(0)
  • 2020-12-09 09:11

    I had the same error when tried to run my tests in a JSF project.

    I´m using Eclipse IDE (kepler). So, I did "project > clean" and then ran the tests again of the same project.

    It worked!

    0 讨论(0)
  • 2020-12-09 09:12

    include the package name with class. It will remove your name. I also got the same issue but adding the package name with class fixed this issue.

    0 讨论(0)
  • 2020-12-09 09:12

    After done trying everything that I found on this issue, in eclipse,

    I selected my project --> right click --> Run as --> Maven generate-sources

    Then I re-ran my TestNG project and it ran perfectly fine without any issues.Hope that helps :)

    0 讨论(0)
提交回复
热议问题