TestNG - Cannot find class in classpath exception though class is present at mentioned location

994 Views Asked by At

I am running my Java project using TestNG and ANT. It was running fine using testng.xml. But after making few changes in my project (renamed few classes and moved the folders). Now on running testng.xml, i am getting the below error:

org.testng.TestNGException: 
Cannot find class in classpath: IntegrationTests.Tests.android_sanity.LoginTest
    at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
    at org.testng.xml.XmlClass.init(XmlClass.java:73)
    at org.testng.xml.XmlClass.<init>(XmlClass.java:59)

Required class is present at the mentioned location. Below is the content of my testng.xml file.

<suite name="Framework">
    <parameter name="browserName" value="firefox" />
    <test name="Automation Tests">
        <groups>
            <run>
                <include name="setUp" />
                <include name="sanity" />
                <include name="tearDown" />
            </run>
        </groups>

        <classes>
            <class name="UITestFramework.CreateSession" />
            <class name="IntegrationTests.Tests.android_sanity.LoginTest" />
        </classes>
    </test>
</suite>

I already tried cleaning and re-building my project several times.

1

There are 1 best solutions below

0
On

Earlier I added Libraries with Add JARs option. Added the required Jars with Add External JARs... option and testng issue resolved. I am still not sure why it happened.

enter image description here