TestNG Errors


Error: TestNG ERROR Cannot find class in classpath

Solution: 

  1. Go to Eclipse> Project > Clean and then run the test cases again. It should work.
  2. And update the maven project (Project > Maven > Update Maven Project)

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.

Related Link: https://stackoverflow.com/questions/7600898/testng-error-cannot-find-class-in-classpath


Error: java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/google/inject/Stage error when using TestNG through eclipse [closed]

Solution:

if you use TestNG version 7.0.0 or upper you may get this error. To solve the issue we need to import jar file or related dependency in your POM file as below:
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.2</version>
</dependency>

Jar Link: https://mvnrepository.com/artifact/com.google.inject/guice/4.2.2

Related link:https://stackoverflow.com/questions/60624926/java-lang-bootstrapmethoderror-java-lang-noclassdeffounderror-com-google-injec

Related Link : https://github.com/cbeust/testng/pull/2264


Share the Knowledge