「Android/kotlin/UnitTest/coroutines」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「app/build.gradle <pre> dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutine...」) |
|||
行4: | 行4: | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2" | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2" | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2" | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2" | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | ExampleUnitTest.kt | ||
+ | <pre> | ||
+ | import kotlinx.coroutines.runBlocking | ||
+ | import org.junit.Test | ||
+ | |||
+ | import org.junit.Assert.* | ||
+ | |||
+ | class ExampleUnitTest { | ||
+ | @Test | ||
+ | fun addition_isCorrect_coroutines() = runBlocking { | ||
+ | assertEquals(4, 2 + 2) | ||
+ | } | ||
} | } | ||
</pre> | </pre> |
2021年2月9日 (火) 17:11時点における最新版
app/build.gradle
dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2" }
ExampleUnitTest.kt
import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.Assert.* class ExampleUnitTest { @Test fun addition_isCorrect_coroutines() = runBlocking { assertEquals(4, 2 + 2) } }