TestNG Errors and Solution

TestNG Errors and solution

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


Error: TestNG 7.4.0 throws java.lang.AssertionError: Couldn’t find resource: jquery.min.js

Solution:

As of TestNG 7.4.0 the below resources loading viz.,

  1. jquery.js
  2. jquery.min.*

Please check your CLASSPATH and ensure that you have at-least https://mvnrepository.com/artifact/org.webjars/jquery/3.5.1

The error is basically indicating that your class path is messed up owing to which TestNG is not able to load jquery.js via the web jars dependency.

TestNG problem: @Before Methods doesn’t run from super class with Groups in child Test classes

Solution: https://youtu.be/qeGl14xEvdA?si=egvMPjLYBXlGrA1O

Share the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *