Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TestNG ERROR Cannot find class in classpath

I'm trying to run testng via command line and I have following things in classpath:

  • testng jar, jar of compiled test case file, and other required jars.
  • testng.xml points to appropriate class in the hierarchy.

Testng doesn't run instead it throws:

[TestNG] [ERROR]  Cannot find class in classpath: (name of testcase file) 

I encountered the same issue before and I just added.

In classpath and it solved the problem. But this time it did not seem to solve it. Any workarounds? Thanks in advance.

like image 623
paragm Avatar asked Sep 29 '11 17:09

paragm


People also ask

Why do we need TestNG exception?

TestNG provides functionality to test such exception scenarios by allowing the user to specify the type of exceptions that are expected to be thrown by a test during execution.

How do you set the path on a TestNG?

Step 1: Go to Eclipse help and click on the button to “Install New Software”. Step 2: Click the Add button and type “TestNG” as name and “http://dl.bintray.com/testng-team/testng-eclipse-release/” as a path. Step 3: Once you add the Path, you will notice a TestNG entry under the name.

How do you resolve TestNG no tests found nothing was run?

Solution. The easiest solution would be to change the @BeforeTest annotation with @Test and execute you Test case / Test Suite.


1 Answers

I just had this problem and I'm pretty confident that it's a bug in the TestNG Plugin for eclipse, since I was able to run my tests from the command line just fine.

The fix that seems to be working for me and others is just to clean your project (ProjectClean). One person had to re-install the whole plugin.

like image 157
Baer Avatar answered Sep 20 '22 17:09

Baer