Hello guys, I have a function `buildRequestUrl` wh...
# testing
k
Hello guys, I have a function 
buildRequestUrl
 which build the URL including headers and query parameters. Now I am working on tests for api call's response. and I am debugging the code where I build the URL which is this  
val uriBuilder = Uri.parse(baseUrl).buildUpon()
But the issue is it throws null pointer exception and result is null (see attached screenshot) How do I solve this issue? I am using below library
Copy code
testImplementation 'junit:junit:4.13'
    testImplementation "org.mockito:mockito-core:3.4.6"
    testImplementation 'androidx.arch.core:core-testing:2.1.0'
    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
I am using below class
Copy code
@ExperimentalCoroutinesApi
class TestCoroutineRule : TestRule {

    private val testCoroutineDispatcher = TestCoroutineDispatcher()

    private val testCoroutineScope = TestCoroutineScope(testCoroutineDispatcher)

    override fun apply(base: Statement, description: Description?) = object : Statement() {
        @Throws(Throwable::class)
        override fun evaluate() {
            Dispatchers.setMain(testCoroutineDispatcher)

            base.evaluate()

            Dispatchers.resetMain()
            testCoroutineScope.cleanupTestCoroutines()
        }
    }

    fun runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) =
        testCoroutineScope.runBlockingTest { block() }
}
I am using the below rule in the test class:
Copy code
@get:Rule
    val testInstantTaskExecutorRule: TestRule = InstantTaskExecutorRule()

    @get:Rule
    val testCoroutineRule = TestCoroutineRule()