Arihant Banthia
Arihant Banthia

Reputation: 43

TestNG ERROR: Cannot find class in classpath after compiling the maven project

I am using maven project and all the testNG tests were working correctly till I compiled and published the project. Now it is giving the error "Cannot find class in classpath" when I execute the tests in eclipse

The test class is in /src/test/java

Below is my sample testng xml:

<suite name="Testing1" parallel="false" verbose="10">
    <test name="Test1">
        <classes>
            <class name="com.test.TestClass"/>
        </classes>
    </test>
</suite>

Can any one tell me why is it not working any more?

Upvotes: 2

Views: 16296

Answers (1)

goodmayhem
goodmayhem

Reputation: 3394

Just do Eclipse> Project > Clean and then run the test cases again. It should work.

What it does in background is, that it will call mvn eclipse:clean in your project directory which will delete your .project and .classpath files and you can also do a mvn eclipse:eclipse - this regenerates your .project and .classpath files. Thus adding the desired class in the classpath.

Upvotes: 2

Related Questions