Hi All, can anyone help me how to write unit test ...
# coroutines
t
Hi All, can anyone help me how to write unit test for this below method?
Copy code
fun pollMessages(): Flow<Message> {

        return channelFlow {

            repeat(noOfReceivers) {
                launch {
                    val messages = sqsClient.fetchMessages()
                    messages.forEach {
                        send(it)
                    }

                }
            }
        }
    }
l
what are you trying to test?
t
Ok.. I want to this method is returning a flow with type as
Message
by mocking sqs client.
a
I mean like you can mock sqs client and attach a collect() to the returned flow and check if mocked messages are the same as you got from the flow.