AndroidとiOSのターゲットでテストを実行する
すべてのプラットフォームでテストスイートを実行します
「AndroidとiOSのターゲットでテストを実行する」はCoddyKit上の無料Kotlin Multiplatform Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはKotlin Multiplatform Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
One Suite, Every Target
A common test compiles for each platform, so you can run the exact same suite on Android and on iOS. 🚀
Gradle Drives It All
You launch tests through Gradle tasks, each one tied to a specific platform target of your shared module.
Run the Android Tests
The testDebugUnitTest task runs your common and JVM tests on the local JVM, no emulator needed.
./gradlew :shared:testDebugUnitTestRun on the iOS Simulator
A target-named task runs the same shared tests on the iOS simulator via Kotlin/Native's runner.
./gradlew :shared:iosSimulatorArm64TestPick the Right Arch
The iOS task name encodes the architecture, so Apple Silicon uses iosSimulatorArm64 while older setups differ.
Run Everything at Once
Calling the broad allTests task executes every target's suite in a single command.
./gradlew :shared:allTestsReading the Report
Gradle writes an HTML report under build/reports, showing which case failed on which platform.
Catch Platform Drift
Running on both targets reveals subtle differences, like number formatting, before they reach your users.
iOS Tests Need a Mac
The iOS simulator target only runs on macOS with Xcode installed, while JVM tests run anywhere.
Wire It Into CI
In CI, run the JVM tests on any runner and the iOS suite on a macOS runner to cover everything.
Green on Both Means Done
When the suite passes on Android and iOS, you have real confidence that shared logic behaves identically. ✅
Quick Check
Pick the Android test task.
Recap
Use Gradle tasks per target: testDebugUnitTest for Android and iosSimulatorArm64Test for iOS, or allTests for both.
よくある質問
「AndroidとiOSのターゲットでテストを実行する」レッスンは無料ですか?
はい。「AndroidとiOSのターゲットでテストを実行する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Kotlin Multiplatform Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
「AndroidとiOSのターゲットでテストを実行する」で何を学びますか?
すべてのプラットフォームでテストスイートを実行します ブラウザで直接実行するハンズオンコードでKotlin Multiplatform Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Kotlin Multiplatform Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのKotlin Multiplatform Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「AndroidとiOSのターゲットでテストを実行する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このKotlin Multiplatform Academyレッスンでコードを書いて実行できますか?
はい。すべてのKotlin Multiplatform Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- commonTestのkotlin.test
- suspend関数とFlowをテストする
- Ktor Clientとリポジトリをフェイク化する
- AndroidとiOSのターゲットでテストを実行する