2

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks it works.. What was happening was that on compiling the peoject the it was removing .classpath files
Saved my day :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.