Kotest: SLF4J dependency issue

Created on 8 Feb 2019  路  5Comments  路  Source: kotest/kotest

When creating a new project in AndroidStudio 3.3, and checking the AndroidX box during the new project wizard, creating a default empty project then adding KotlinTest as instructed:

android {
    testOptions {
        unitTests.all {
            useJUnitPlatform()
        }
    }
}

dependencies {
    testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.2.1'
}

Then add a simple test using KotlinTest, the test executes no problem but gives this warning:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

I'm new to Android and gradle, so don't really understand what's going on here. Is it some kind of internal dependency error, or should end-users also add a SLF4J implementation (maybe a testImplementation line??) for it to work without warnings?

bug

Most helpful comment

@Xerus2000 if that's the fix, then it should be added to the Readme docs.
It's quite confusing to see that warning in every test launch.

All 5 comments

@Kerooker can you help with this as you're our android man :)

I'm not sure if I can help with this.

I used to have this kind of warn even without KotlinTest, another lib would introduce it.

I usually just ignore it :P

But, the issue here is that Android uses LogCat by default, and I don't think SLF4J integrates with it. For this, you would have to add some implementation compatible with SLF4J for your unit tests.

https://stackoverflow.com/questions/7421612/slf4j-failed-to-load-class-org-slf4j-impl-staticloggerbinder

Currently, there isn't much we can do for you. This issue can be ignored, although a pain in the ass, it won't halt execution and won't fail your build

This has nothing to do with Android. SLF4J is a logging facade employed by some dependeny that needs to bind to an actual logging implementation, otherwise it warns you.
You can solve this by attaching the sf4j-simple implementation in your tests:

testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.26'

@Xerus2000 if that's the fix, then it should be added to the Readme docs.
It's quite confusing to see that warning in every test launch.

slf4j has been removed as a dependency in kotest in master (for release 4.0).

Was this page helpful?
0 / 5 - 0 ratings