1

I have installed my testNG from the marketplace. I am studying software testing using Selenium with Java. I expect a print out with this basic code, instead, it displays an error.

package ui;

import org.testng.annotations.Test;

public class LoginTest {
    
    @Test
    public void loginTest()
    {
        System.out.println("hi hello");
    }
}

Following is the error. I did not see error in my script or the library. Is there anything I am missing?

[RemoteTestNG] detected TestNG version 7.8.0
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.testng.log4testng.Logger.lambda$getLogger$0(Logger.java:30)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
    at org.testng.log4testng.Logger.getLogger(Logger.java:30)
    at org.testng.TestNG.<clinit>(TestNG.java:113)
    at org.testng.remote.support.RemoteTestNGFactory7_8.createRemoteTestNG(RemoteTestNGFactory7_8.java:16)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:67)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 6 more
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
taerese
  • 53
  • 5

2 Answers2

1

I added the following dependencies are the error was gone,

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>2.0.7</version>
</dependency>

This was the output. Notice some information in first few lines below. Although the testNG still works.

[RemoteTestNG] detected TestNG version 7.8.0
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
hi hello
PASSED: ui.LoginTest.loginTest

===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Passes: 1, Failures: 0, Skips: 0
===============================================

taerese
  • 53
  • 5
0

It is just a warning, I have the same, and it does not affect the test execution. You can simply ignore that