<@U54CM9PGS> I'm still having problems with test d...
# testballoon
d
@Oliver.O I'm still having problems with test detection... I added that debug logging block, and the plugin said it found that test when trying to run the whole suite, but the ide doesn't show the gutter icons and the test doesn't run in practice... this module is in a project with a few kmp library modules, but it itself is an android module, and I added the core-jvm dep to it along with the plugin.
o
KMP+Android configuration is still delicate (unrelated to TestBalloon), as explained in the docs:
Google is deprecating the
com.android.application
plugin in favor of
com.android.kotlin.multiplatform.library
. Android-KMP integration is currently a moving target and there are multiple issues, so please test if it meets your needs.
But it can work if every detail is configured carefully. It worked last time with your local tests. Are you now trying to run a device (instrumented) test, where • the dependency must be configured differently, and • the IDE plugin does not yet support gutter icons?
d
no, just unit tests
and the test doesn't even get run when I try running the whole test folder there.
o
So let's start with the IDE, what does the test function look like?
d
Copy code
val SuggestionAwarePlayerServiceTest2 by testSuite {
    class Context {
        val fakeDelegate = FakePlayerService()
        val repo = object : SuggestionsRepository {
            override suspend fun getSuggestedStreams(
                basedOn: StartedFrom,
                currentQueueSize: Int,
                limit: Int
            ): List<Stream>? = null
        }

        val suggested = listOf(sampleStream(100), sampleStream(101))
        val service = SuggestionAwarePlayerService(fakeDelegate, repo)
    }

    @TestRegistering
    fun test(name: String, action: suspend Context.() -> Unit) =
        this.test(name) { Context().action() }

    test("when startedFrom is provided and streams empty, seeds from suggestions") {
        // Initially empty
        assertEquals(PlayerQueue.EMPTY, service.currentQueue.value)

        // Call with startedFrom but no streams
        val startedFrom: StartedFrom = CollectionRef(10, StreamContainerType.ALBUM, "A", "", true)
        service.setQueue(startedFrom, emptyList())

        // Should set queue to suggestions with same startedFrom
        assertEquals(PlayerQueue(startedFrom, suggested, 0), service.currentQueue.value)
    }
}
o
That looks OK. Is this using the now deprecated plugin "com.android.application"?
d
oh.. yeah. But that's not a change only for kmp?
And this module isn't a library, nor is it kmp yet, it just depends on kmp libs, but it's the app I'm migrating
o
That's outside the IDE plugin's current support for KMP. So TestBalloon will still run those tests, but you won't see the gutter icons. The IDE plugin needs extra Android target support which will be fixed along with issue #33. You will see the run gutter icons on local (unit) tests using the new "com.android.kotlin.multiplatform.library" Gradle plugin, as you've seen before.
So the next question is: Why don't the tests run? What does the Gradle configuration look like?
d
Yeah, in the end it does run the test (just last amongst the other junit vintage tests...). I guess one test was hanging at this moment and it just didn't get to the test balloon test. I guess I assumed the test was going to be run before. Is there any way to fix this to get those gutter icons (maybe if I switch plugins?)? It makes life so much simpler...
o
Not at this time. The IDE plugin needs to recognize the Android Gradle test targets. And with instrumented tests, it needs to create a completely different type of run configuration. So this will be addressed, but it will take some time. It's high on the priority list, though.
d
Ok, thanks for the help! Btw, I think this is a mistake in the First steps docs:
Google is deprecating the
com.android.application
plugin in favor of
com.android.kotlin.multiplatform.library
. Android-KMP integration is currently a moving target and there are multiple issues, so please test if it meets your needs.
it should be com.android.library? And also it might be nice to mention this caveat for application test that don't have gutter icons there (so people like me don't assume test balloon not working...).
o
If have added issue #40 to track the IDE gutter icons with
com.android.application
separately. Fortunately, TestBalloon's list of open issues is small, so you can easily see existing limitations. The current recommendation by Google is to use only
com.android.kotlin.multiplatform.library
with KMP, and create a separate non-KMP module with
com.android.application
, importing from KMP modules as necessary.
d
Meaning just a wiring module using application?
I guess that's quite a bit of work for companies trying to gradually migrate non-kmp projects to kmp, to just dive straight in... I guess maybe I could try making a library module with only an android target and wiring it with the application module... but I was hoping to avoid making such changes for now.
o
I guess you need to knock at Google's door for that.