-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
More of a question than an issue, but is there any reason why a user couldn't/shouldn't be able to apply both of the new test interceptor interfaces to a class, to make it compatible with both suspending and non-suspending test cases? E.g.
class TemporaryFolder : TestInterceptor, CoroutineTestInterceptor {
lateinit var root: Path
private set
override suspend fun intercept(testFunction: CoroutineTestFunction) =
handleTempFolder { testFunction() }
override fun intercept(testFunction: TestFunction) =
handleTempFolder { testFunction() }
private inline fun handleTempFolder(testFunction: () -> Unit) = try {
root = createTempDirectory().toOkioPath()
testFunction()
} finally {
FileSystem.SYSTEM.deleteRecursively(root)
}
Right now this gives an error in suspending test cases because of this bit acting as though interceptors can't implement both interfaces.
Without this, we'd just have to make separate (but functionally the same) implementations of any interceptors we use, which would be a bit of a faff IMO. Especially if there's a test class with a mixture of suspending and non-suspending test cases.
Just wanted to clarify your intent on this before jumping in to make a "fix" for an intended design decision
Metadata
Metadata
Assignees
Labels
No labels