Skip to content

Commit f0bdf00

Browse files
authored
Increase the deprecation levels for the old test framework API (#4198)
1 parent 5c8e650 commit f0bdf00

17 files changed

+75
-679
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ suspend fun main() = coroutineScope {
4343
* Integration with `Window` via [Window.asCoroutineDispatcher], etc.
4444
* [test](kotlinx-coroutines-test/README.md) — test utilities for coroutines:
4545
* [Dispatchers.setMain] to override [Dispatchers.Main] in tests;
46-
* [TestCoroutineScope] to test suspending functions and coroutines.
46+
* [runTest] and [TestScope] to test suspending functions and coroutines.
4747
* [debug](kotlinx-coroutines-debug/README.md) — debug utilities for coroutines:
4848
* [DebugProbes] API to probe, keep track of, print and dump active coroutines;
4949
* [CoroutinesTimeout] test rule to automatically dump coroutines on test timeout.
@@ -240,7 +240,8 @@ See [Contributing Guidelines](CONTRIBUTING.md).
240240
<!--- INDEX kotlinx.coroutines.test -->
241241

242242
[Dispatchers.setMain]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/set-main.html
243-
[TestCoroutineScope]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scope/index.html
243+
[runTest]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/run-test.html
244+
[TestScope]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-scope/index.html
244245

245246
<!--- MODULE kotlinx-coroutines-debug -->
246247
<!--- INDEX kotlinx.coroutines.debug -->

kotlinx-coroutines-test/api/kotlinx-coroutines-test.api

+5-37
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
public abstract interface class kotlinx/coroutines/test/DelayController {
2-
public abstract fun advanceTimeBy (J)J
3-
public abstract fun advanceUntilIdle ()J
4-
public abstract fun cleanupTestCoroutines ()V
5-
public abstract fun getCurrentTime ()J
6-
public abstract fun pauseDispatcher ()V
7-
public abstract fun pauseDispatcher (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
8-
public abstract fun resumeDispatcher ()V
9-
public abstract fun runCurrent ()V
10-
}
11-
121
public final class kotlinx/coroutines/test/TestBuildersKt {
132
public static final fun runBlockingTest (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;)V
143
public static final fun runBlockingTest (Lkotlinx/coroutines/test/TestCoroutineDispatcher;Lkotlin/jvm/functions/Function2;)V
@@ -31,21 +20,17 @@ public final class kotlinx/coroutines/test/TestBuildersKt {
3120
public static synthetic fun runTestWithLegacyScope$default (Lkotlin/coroutines/CoroutineContext;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
3221
}
3322

34-
public final class kotlinx/coroutines/test/TestCoroutineDispatcher : kotlinx/coroutines/test/TestDispatcher, kotlinx/coroutines/Delay, kotlinx/coroutines/test/SchedulerAsDelayController {
23+
public final class kotlinx/coroutines/test/TestCoroutineDispatcher : kotlinx/coroutines/test/TestDispatcher, kotlinx/coroutines/Delay {
3524
public fun <init> ()V
3625
public fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;)V
3726
public synthetic fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
38-
public fun advanceTimeBy (J)J
39-
public fun advanceUntilIdle ()J
40-
public fun cleanupTestCoroutines ()V
27+
public final fun advanceUntilIdle ()J
28+
public final fun cleanupTestCoroutines ()V
4129
public fun dispatch (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V
4230
public fun dispatchYield (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V
43-
public fun getCurrentTime ()J
31+
public final fun getCurrentTime ()J
4432
public fun getScheduler ()Lkotlinx/coroutines/test/TestCoroutineScheduler;
45-
public fun pauseDispatcher ()V
46-
public fun pauseDispatcher (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
47-
public fun resumeDispatcher ()V
48-
public fun runCurrent ()V
33+
public final fun runCurrent ()V
4934
public fun toString ()Ljava/lang/String;
5035
}
5136

@@ -56,13 +41,6 @@ public final class kotlinx/coroutines/test/TestCoroutineDispatchersKt {
5641
public static synthetic fun UnconfinedTestDispatcher$default (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestDispatcher;
5742
}
5843

59-
public final class kotlinx/coroutines/test/TestCoroutineExceptionHandler : kotlin/coroutines/AbstractCoroutineContextElement, kotlinx/coroutines/CoroutineExceptionHandler, kotlinx/coroutines/test/UncaughtExceptionCaptor {
60-
public fun <init> ()V
61-
public fun cleanupTestCoroutines ()V
62-
public fun getUncaughtExceptions ()Ljava/util/List;
63-
public fun handleException (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Throwable;)V
64-
}
65-
6644
public final class kotlinx/coroutines/test/TestCoroutineScheduler : kotlin/coroutines/AbstractCoroutineContextElement, kotlin/coroutines/CoroutineContext$Element {
6745
public static final field Key Lkotlinx/coroutines/test/TestCoroutineScheduler$Key;
6846
public fun <init> ()V
@@ -85,15 +63,10 @@ public abstract interface class kotlinx/coroutines/test/TestCoroutineScope : kot
8563
public final class kotlinx/coroutines/test/TestCoroutineScopeKt {
8664
public static final fun TestCoroutineScope (Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/test/TestCoroutineScope;
8765
public static synthetic fun TestCoroutineScope$default (Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestCoroutineScope;
88-
public static final fun advanceTimeBy (Lkotlinx/coroutines/test/TestCoroutineScope;J)V
8966
public static final fun advanceUntilIdle (Lkotlinx/coroutines/test/TestCoroutineScope;)V
9067
public static final fun createTestCoroutineScope (Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/test/TestCoroutineScope;
9168
public static synthetic fun createTestCoroutineScope$default (Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestCoroutineScope;
9269
public static final fun getCurrentTime (Lkotlinx/coroutines/test/TestCoroutineScope;)J
93-
public static final fun getUncaughtExceptions (Lkotlinx/coroutines/test/TestCoroutineScope;)Ljava/util/List;
94-
public static final fun pauseDispatcher (Lkotlinx/coroutines/test/TestCoroutineScope;)V
95-
public static final fun pauseDispatcher (Lkotlinx/coroutines/test/TestCoroutineScope;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
96-
public static final fun resumeDispatcher (Lkotlinx/coroutines/test/TestCoroutineScope;)V
9770
public static final fun runCurrent (Lkotlinx/coroutines/test/TestCoroutineScope;)V
9871
}
9972

@@ -128,8 +101,3 @@ public final class kotlinx/coroutines/test/TestScopeKt {
128101
public static final fun setCatchNonTestRelatedExceptions (Z)V
129102
}
130103

131-
public abstract interface class kotlinx/coroutines/test/UncaughtExceptionCaptor {
132-
public abstract fun cleanupTestCoroutines ()V
133-
public abstract fun getUncaughtExceptions ()Ljava/util/List;
134-
}
135-

kotlinx-coroutines-test/jvm/src/migration/DelayController.kt

-206
This file was deleted.

kotlinx-coroutines-test/jvm/src/migration/TestBuildersDeprecated.kt

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@file:Suppress("DEPRECATION")
1+
@file:Suppress("DEPRECATION", "DEPRECATION_ERROR")
22
@file:JvmName("TestBuildersKt")
33
@file:JvmMultifileClass
44

@@ -51,9 +51,9 @@ import kotlin.time.Duration.Companion.milliseconds
5151
"Use `runTest` instead to support completing from other dispatchers. " +
5252
"Please see the migration guide for details: " +
5353
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
54-
level = DeprecationLevel.WARNING
54+
level = DeprecationLevel.ERROR
5555
)
56-
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
56+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
5757
public fun runBlockingTest(
5858
context: CoroutineContext = EmptyCoroutineContext,
5959
testBody: suspend TestCoroutineScope.() -> Unit
@@ -73,8 +73,8 @@ public fun runBlockingTest(
7373
/**
7474
* A version of [runBlockingTest] that works with [TestScope].
7575
*/
76-
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
77-
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
76+
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.ERROR)
77+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
7878
public fun runBlockingTestOnTestScope(
7979
context: CoroutineContext = EmptyCoroutineContext,
8080
testBody: suspend TestScope.() -> Unit
@@ -121,17 +121,17 @@ public fun runBlockingTestOnTestScope(
121121
"Use `runTest` instead to support completing from other dispatchers. " +
122122
"Please see the migration guide for details: " +
123123
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
124-
level = DeprecationLevel.WARNING
124+
level = DeprecationLevel.ERROR
125125
)
126-
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
126+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
127127
public fun TestCoroutineScope.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
128128
runBlockingTest(coroutineContext, block)
129129

130130
/**
131131
* Convenience method for calling [runBlockingTestOnTestScope] on an existing [TestScope].
132132
*/
133-
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
134-
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
133+
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.ERROR)
134+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
135135
public fun TestScope.runBlockingTest(block: suspend TestScope.() -> Unit): Unit =
136136
runBlockingTestOnTestScope(coroutineContext, block)
137137

@@ -147,18 +147,18 @@ public fun TestScope.runBlockingTest(block: suspend TestScope.() -> Unit): Unit
147147
"Use `runTest` instead to support completing from other dispatchers. " +
148148
"Please see the migration guide for details: " +
149149
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
150-
level = DeprecationLevel.WARNING
150+
level = DeprecationLevel.ERROR
151151
)
152-
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
152+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
153153
public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
154154
runBlockingTest(this, block)
155155

156156
/**
157157
* This is an overload of [runTest] that works with [TestCoroutineScope].
158158
*/
159159
@ExperimentalCoroutinesApi
160-
@Deprecated("Use `runTest` instead.", level = DeprecationLevel.WARNING)
161-
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
160+
@Deprecated("Use `runTest` instead.", level = DeprecationLevel.ERROR)
161+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
162162
public fun runTestWithLegacyScope(
163163
context: CoroutineContext = EmptyCoroutineContext,
164164
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
@@ -196,8 +196,8 @@ public fun runTestWithLegacyScope(
196196
* immediately from the test body. See the docs for [TestResult] for details.
197197
*/
198198
@ExperimentalCoroutinesApi
199-
@Deprecated("Use `TestScope.runTest` instead.", level = DeprecationLevel.WARNING)
200-
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
199+
@Deprecated("Use `TestScope.runTest` instead.", level = DeprecationLevel.ERROR)
200+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
201201
public fun TestCoroutineScope.runTest(
202202
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
203203
block: suspend TestCoroutineScope.() -> Unit

0 commit comments

Comments
 (0)