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

前端 未结 30 1092
礼貌的吻别
礼貌的吻别 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:13

    I had this same problem when I imported my project from one PC to another on IntelliJ IDEA.

    Below Solution worked for me:

    1. Import project using Git.
    2. After Importing IDE would prompt you a dialog on the bottom right corner saying "Import as Gradle", you need to select that but make Sure you have set JAVA_HOME and GRADLE(Gradle Home or Gradle wrapper both should work) properly.
    3. Run the build.gradle and make sure all the dependencies are downloaded correctly without any error.
    4. Now move to your Test Case and try to run with TestNG or JUnit and if you have followed above 3 steps properly you should able to run the test case.
    0 讨论(0)
  • 2020-12-09 09:16

    For me the problem was very strange.
    I have a testng.xml file at the root of my Eclipse project. When I changed the file through Eclipse, it wasn't changing the testng.xml file in my directory.

    Turns out it made a copy of the folder into the eclipse workspace..

    Hope this helps someone out

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

    Go to Project>Build Path>Configure Build Path>Libraries>Remove Error libraries

    After Refresh project and run again program.

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

    I had similar issue and the project had some build errors. I did sudo -R 777 to the project and then I cleaned my project. After that it worked fine.

    Hope it helps.

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

    Note: You have to specify class name along with packages as given below.

    <suite name="testNGLearning">
        <test name="simpleTest">
            <classes>
                <class name="testngTests.TestNGSimpleTest" />
                <class name="testngTests.TestMessageUtil" />
            </classes>
        </test>
    </suite>
    
    0 讨论(0)
  • 2020-12-09 09:18

    I had no problems with this until recently.

    Now I had to move the suite's xml test file into the root of the project I was testing.

    It may be that there is a setting to point at the classes I am testing, but I have not found it.

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