Skip to content

Only run blocking interceptors for blocking tests, and suspending for suspending #204

@JakeWharton

Description

@JakeWharton

A similar case that'd be nice to support is something like:

class SuspendingInterceptor : CoroutineTestInterceptor {
  override suspend fun intercept(testFunction: CoroutineTestFunction) {
    println("intercepting from SuspendingInterceptor")
    testFunction()
  }
}

class NonSuspendingInterceptor : TestInterceptor {
  override fun intercept(testFunction: TestFunction) {
    println("intercepting from NonSuspendingInterceptor")
    testFunction()
  }
}

class ExampleTest {
  @InterceptTest val nonSuspending = NonSuspendingInterceptor()
  @InterceptTest val suspending = SuspendingInterceptor()

  @Test fun suspendingTest() = runTest { println("running suspendingTest") }
  @Test fun nonSuspendingTest() = println("running nonSuspendingTest")
}

then have the SuspendingInterceptor pick up the suspendingTest, and NonSuspendingInterceptor pick up the nonSuspendingTest.

Originally posted by @jonapoul in #188

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions