├── .github └── workflows │ ├── compilation-check.yml │ └── publish.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── run-check.sh ├── run-publish.sh ├── sample └── mpp-library │ ├── build.gradle.kts │ └── src │ ├── androidMain │ └── AndroidManifest.xml │ └── commonMain │ └── kotlin │ └── com │ └── icerockdev │ └── library │ └── Greeting.kt ├── settings.gradle.kts ├── test-build-logic ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ ├── android-app-convention.gradle.kts │ ├── android-base-convention.gradle.kts │ ├── android-library-convention.gradle.kts │ ├── detekt-convention.gradle.kts │ ├── kmp-library-convention.gradle.kts │ ├── publication-convention.gradle.kts │ └── stub-javadoc-convention.gradle.kts ├── test-core ├── build.gradle.kts └── src │ ├── androidMain │ ├── AndroidManifest.xml │ └── kotlin │ │ └── dev │ │ └── icerock │ │ └── moko │ │ └── test │ │ ├── AndroidArchitectureInstantTaskExecutorRule.kt │ │ ├── TestCoroutineDispatcherRule.kt │ │ ├── TestCoroutineRule.kt │ │ ├── TestRule.kt │ │ ├── cases │ │ └── InstantTaskRule.kt │ │ └── runBlocking.kt │ ├── commonMain │ └── kotlin │ │ └── dev │ │ └── icerock │ │ └── moko │ │ └── test │ │ ├── AndroidArchitectureInstantTaskExecutorRule.kt │ │ ├── CoroutineScopeTestUtils.kt │ │ ├── TestCoroutineDispatcherRule.kt │ │ ├── TestRule.kt │ │ ├── cases │ │ ├── InstantTaskRule.kt │ │ └── TestCases.kt │ │ └── runBlocking.kt │ ├── jsMain │ └── kotlin │ │ └── dev │ │ └── icerock │ │ └── moko │ │ └── test │ │ └── runBlocking.kt │ ├── nonAndroidJsMain │ └── kotlin │ │ └── dev │ │ └── icerock │ │ └── moko │ │ └── test │ │ └── runBlocking.kt │ └── nonAndroidMain │ └── kotlin │ └── dev │ └── icerock │ └── moko │ └── test │ ├── AndroidArchitectureInstantTaskExecutorRule.kt │ ├── TestCoroutineDispatcherRule.kt │ └── cases │ └── InstantTaskRule.kt └── test-robolectric ├── build.gradle.kts └── src ├── androidMain ├── AndroidManifest.xml └── kotlin │ └── dev │ └── icerock │ └── moko │ └── test │ └── robolectric │ └── RobolectricTestCases.kt ├── commonMain └── kotlin │ └── dev │ └── icerock │ └── moko │ └── test │ └── robolectric │ └── RobolectricTestCases.kt └── nonAndroidMain └── kotlin └── dev └── icerock └── moko └── test └── robolectric └── RobolectricTestCases.kt /.github/workflows/compilation-check.yml: -------------------------------------------------------------------------------- 1 | name: KMP library compilation check 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | - develop 8 | 9 | jobs: 10 | test: 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [ macos-latest, windows-latest, ubuntu-latest ] 15 | steps: 16 | - uses: actions/checkout@v1 17 | - name: Set up JDK 11 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 11 21 | - name: Check build 22 | run: ./run-check.sh "${{ matrix.os }}" 23 | shell: bash 24 | - name: Publish Test Report 25 | uses: mikepenz/action-junit-report@v2 26 | if: ${{ always() }} 27 | with: 28 | report_paths: '**/build/test-results/**/TEST-*.xml' 29 | github_token: ${{ secrets.GITHUB_TOKEN }} 30 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Create release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | version: 7 | description: 'Version' 8 | default: '0.1.0' 9 | required: true 10 | 11 | jobs: 12 | publish: 13 | name: Publish library at mavenCentral 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | os: [ macos-latest, windows-latest, ubuntu-latest ] 18 | env: 19 | OSSRH_USER: ${{ secrets.OSSRH_USER }} 20 | OSSRH_KEY: ${{ secrets.OSSRH_KEY }} 21 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEYID }} 22 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} 23 | SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }} 24 | 25 | steps: 26 | - uses: actions/checkout@v1 27 | - name: Set up JDK 11 28 | uses: actions/setup-java@v1 29 | with: 30 | java-version: 11 31 | - name: Build and publish 32 | run: ./run-publish.sh "${{ matrix.os }}" 33 | shell: bash 34 | 35 | release: 36 | name: Create release 37 | needs: publish 38 | runs-on: ubuntu-latest 39 | steps: 40 | - name: Create Release 41 | id: create_release 42 | uses: actions/create-release@v1 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | with: 46 | commitish: ${{ github.ref }} 47 | tag_name: release/${{ github.event.inputs.version }} 48 | release_name: ${{ github.event.inputs.version }} 49 | body: "Will be filled later" 50 | draft: true -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .settings 3 | .project 4 | .classpath 5 | .vscode 6 | .idea 7 | build 8 | *.iml 9 | Pods 10 | xcuserdata 11 | local.properties 12 | local.gradle 13 | kotlin-js-store/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Do’s and Don’ts 2 | 3 | * **Search tickets before you file a new one.** Add to tickets if you have new information about the issue. 4 | * **Keep tickets short but sweet.** Make sure you include all the context needed to solve the issue. Don't overdo it. Great tickets allow us to focus on solving problems instead of discussing them. 5 | * **Take care of your ticket.** When you spend time to report a ticket with care we'll enjoy fixing it for you. 6 | * **Use [GitHub-flavored Markdown](https://help.github.com/articles/markdown-basics/).** Especially put code blocks and console outputs in backticks (```` ``` ````). That increases the readability. Bonus points for applying the appropriate syntax highlighting. 7 | 8 | ## Bug Reports 9 | 10 | In short, since you are most likely a developer, provide a ticket that you _yourself_ would _like_ to receive. 11 | 12 | First check if you are using the latest library version and Kotlin version before filing a ticket. 13 | 14 | Please include steps to reproduce and _all_ other relevant information, including any other relevant dependency and version information. 15 | 16 | ## Feature Requests 17 | 18 | Please try to be precise about the proposed outcome of the feature and how it 19 | would related to existing features. 20 | 21 | 22 | ## Pull Requests 23 | 24 | We **love** pull requests! 25 | 26 | All contributions _will_ be licensed under the Apache 2 license. 27 | 28 | Code/comments should adhere to the following rules: 29 | 30 | * Names should be descriptive and concise. 31 | * Use four spaces and no tabs. 32 | * Remember that source code usually gets written once and read often: ensure 33 | the reader doesn't have to make guesses. Make sure that the purpose and inner 34 | logic are either obvious to a reasonably skilled professional, or add a 35 | comment that explains it. 36 | * Please add a detailed description. 37 | 38 | If you consistently contribute improvements and/or bug fixes, we're happy to make you a maintainer. -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![moko-test](https://user-images.githubusercontent.com/5010169/128706360-5b66ad24-a732-4e20-8e7f-feb8f98e997f.png) 2 | [![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) 3 | [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/test-core) ](https://repo1.maven.org/maven2/dev/icerock/moko/test-core/) 4 | ![kotlin-version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=dev.icerock.moko&name=test-core) 5 | 6 | # Mobile Kotlin test utils 7 | 8 | This is a Kotlin Multiplatform library that provides utilities for run tests. 9 | 10 | ## Table of Contents 11 | 12 | - [Features](#features) 13 | - [Requirements](#requirements) 14 | - [Installation](#installation) 15 | - [Usage](#usage) 16 | - [Samples](#samples) 17 | - [Set Up Locally](#set-up-locally) 18 | - [Contributing](#contributing) 19 | - [License](#license) 20 | 21 | ## Features 22 | 23 | - **...** - ...; 24 | 25 | ## Requirements 26 | 27 | - Gradle version 6.8+ 28 | - Android API 16+ 29 | - iOS version 11.0+ 30 | 31 | ## Installation 32 | 33 | root build.gradle 34 | 35 | ```groovy 36 | allprojects { 37 | repositories { 38 | mavenCentral() 39 | } 40 | } 41 | ``` 42 | 43 | project build.gradle 44 | 45 | ```groovy 46 | dependencies { 47 | commonTestApi("dev.icerock.moko:test-core:0.6.1") 48 | commonTestApi("dev.icerock.moko:test-roboelectric:0.6.1") // for android-roboelectric tests support 49 | } 50 | ``` 51 | 52 | ## Usage 53 | 54 | ### runBlocking 55 | 56 | ```kotlin 57 | import dev.icerock.moko.test.runBlocking 58 | 59 | fun test() { 60 | runBlocking { 61 | // some suspend functions 62 | } 63 | } 64 | ``` 65 | 66 | ### TestCases 67 | 68 | ```kotlin 69 | class MyTests : TestCases() { 70 | override val rules: List = listOf( 71 | InstantTaskRule() // apply https://developer.android.com/reference/android/arch/core/executor/testing/InstantTaskExecutorRule for android 72 | ) 73 | 74 | @Test 75 | fun `my test`() { 76 | // ... 77 | } 78 | } 79 | ``` 80 | 81 | also available creation of own rules by inherit `dev.icerock.moko.test.cases.TestCases.Rule` 82 | 83 | ```kotlin 84 | class InstantTaskRule : TestCases.Rule { 85 | 86 | override fun setup() { 87 | // do some action before each test 88 | } 89 | 90 | override fun tearDown() { 91 | // do some action after each test 92 | } 93 | } 94 | ``` 95 | 96 | ### Roboelectric support 97 | 98 | ```kotlin 99 | class MyTests : RoboelectricTestCases() { 100 | override val rules: List = listOf( 101 | // ... 102 | ) 103 | 104 | @Test 105 | fun `my test`() { 106 | // ... 107 | } 108 | } 109 | ``` 110 | 111 | ## Samples 112 | 113 | Please see more examples in the [sample directory](sample). 114 | 115 | ## Set Up Locally 116 | 117 | - The [test directory](test) contains the `test` library; 118 | - In [sample directory](sample) contains sample mpp-library with tests. 119 | 120 | ## Contributing 121 | 122 | All development (both new features and bug fixes) is performed in the `develop` branch. This 123 | way `master` always contains the sources of the most recently released version. Please send PRs with 124 | bug fixes to the `develop` branch. Documentation fixes in the markdown files are an exception to 125 | this rule. They are updated directly in `master`. 126 | 127 | The `develop` branch is pushed to `master` on release. 128 | 129 | For more details on contributing please see the [contributing guide](CONTRIBUTING.md). 130 | 131 | ## License 132 | 133 | Copyright 2021 IceRock MAG Inc. 134 | 135 | Licensed under the Apache License, Version 2.0 (the "License"); 136 | you may not use this file except in compliance with the License. 137 | You may obtain a copy of the License at 138 | 139 | http://www.apache.org/licenses/LICENSE-2.0 140 | 141 | Unless required by applicable law or agreed to in writing, software 142 | distributed under the License is distributed on an "AS IS" BASIS, 143 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 144 | See the License for the specific language governing permissions and 145 | limitations under the License. 146 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | google() 5 | gradlePluginPortal() 6 | } 7 | dependencies { 8 | classpath(":test-build-logic") 9 | } 10 | } 11 | 12 | plugins { 13 | alias(libs.plugins.nexusPublish) 14 | } 15 | 16 | nexusPublishing { 17 | repositories { 18 | sonatype { 19 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) 20 | username.set(System.getenv("OSSRH_USER")) 21 | password.set(System.getenv("OSSRH_KEY")) 22 | } 23 | } 24 | } 25 | 26 | val mokoVersion = libs.versions.mokoTestVersion.get() 27 | allprojects { 28 | group = "dev.icerock.moko" 29 | version = mokoVersion 30 | } 31 | 32 | // temporary fix for Apple Silicon (remove after 1.6.20 update) 33 | rootProject.plugins.withType { 34 | rootProject.the().nodeVersion = "16.0.0" 35 | } 36 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4096m 2 | org.gradle.configureondemand=false 3 | org.gradle.parallel=true 4 | 5 | kotlin.code.style=official 6 | kotlin.native.enableDependencyPropagation=false 7 | kotlin.mpp.enableGranularSourceSetsMetadata=true 8 | kotlin.mpp.enableCompatibilityMetadataVariant=true 9 | 10 | android.useAndroidX=true 11 | 12 | mobile.multiplatform.iosTargetWarning=false 13 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | kotlinVersion = "1.6.10" 3 | coroutinesVersion = "1.6.0" 4 | mokoTestVersion = "0.6.1" 5 | 6 | [libraries] 7 | robolectric = { module = "org.robolectric:robolectric", version = "4.6.1" } 8 | androidCoreTesting = { module = "androidx.arch.core:core-testing", version = "2.1.0" } 9 | 10 | coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesVersion" } 11 | coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutinesVersion" } 12 | 13 | mokoTestCore = { module = "dev.icerock.moko:test-core", version.ref = "mokoTestVersion" } 14 | kotlinTestJUnit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinVersion" } 15 | 16 | # gradle plugins 17 | kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" } 18 | mobileMultiplatformGradlePlugin = { module = "dev.icerock:mobile-multiplatform", version = "0.13.0" } 19 | androidGradlePlugin = { module = "com.android.tools.build:gradle", version = "7.0.4" } 20 | detektGradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version = "1.19.0" } 21 | 22 | [plugins] 23 | nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version = "1.1.0" } 24 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icerockdev/moko-test/addd85fa0c43eb9edf2a820b57c6b24a13bc9eeb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /run-check.sh: -------------------------------------------------------------------------------- 1 | if [ "$1" == "macos-latest" ]; then 2 | ./gradlew detektIosArm32Main \ 3 | detektIosArm64Main \ 4 | detektIosSimulatorArm64Main \ 5 | detektIosX64Main \ 6 | detektMacosArm64Main \ 7 | detektMacosX64Main \ 8 | detektTvosArm64Main \ 9 | detektTvosSimulatorArm64Main \ 10 | detektTvosX64Main \ 11 | detektWatchosArm32Main \ 12 | detektWatchosArm64Main \ 13 | detektWatchosSimulatorArm64Main \ 14 | detektWatchosX64Main \ 15 | detektWatchosX86Main \ 16 | iosSimulatorArm64Test \ 17 | iosX64Test \ 18 | macosArm64Test \ 19 | macosX64Test \ 20 | tvosSimulatorArm64Test \ 21 | tvosX64Test \ 22 | watchosSimulatorArm64Test \ 23 | watchosX64Test \ 24 | watchosX86Test \ 25 | publishIosArm32PublicationToMavenLocal \ 26 | publishIosArm64PublicationToMavenLocal \ 27 | publishIosSimulatorArm64PublicationToMavenLocal \ 28 | publishIosX64PublicationToMavenLocal \ 29 | publishMacosArm64PublicationToMavenLocal \ 30 | publishMacosX64PublicationToMavenLocal \ 31 | publishTvosArm64PublicationToMavenLocal \ 32 | publishTvosSimulatorArm64PublicationToMavenLocal \ 33 | publishTvosX64PublicationToMavenLocal \ 34 | publishWatchosArm32PublicationToMavenLocal \ 35 | publishWatchosArm64PublicationToMavenLocal \ 36 | publishWatchosSimulatorArm64PublicationToMavenLocal \ 37 | publishWatchosX64PublicationToMavenLocal \ 38 | publishWatchosX86PublicationToMavenLocal 39 | elif [ "$1" == "windows-latest" ]; then 40 | ./gradlew detektMingwX64Main \ 41 | mingwX64Test \ 42 | publishMingwX64PublicationToMavenLocal 43 | elif [ "$1" == "ubuntu-latest" ]; then 44 | ./gradlew detektWithoutTests build publishToMavenLocal 45 | else 46 | ./gradlew detektWithoutTests build publishToMavenLocal 47 | fi -------------------------------------------------------------------------------- /run-publish.sh: -------------------------------------------------------------------------------- 1 | OS=$1 2 | 3 | if [ "$OS" == "macos-latest" ]; then 4 | ./gradlew publishIosArm32PublicationToSonatypeRepository \ 5 | publishIosArm64PublicationToSonatypeRepository \ 6 | publishIosSimulatorArm64PublicationToSonatypeRepository \ 7 | publishIosX64PublicationToSonatypeRepository \ 8 | publishMacosArm64PublicationToSonatypeRepository \ 9 | publishMacosX64PublicationToSonatypeRepository \ 10 | publishTvosArm64PublicationToSonatypeRepository \ 11 | publishTvosSimulatorArm64PublicationToSonatypeRepository \ 12 | publishTvosX64PublicationToSonatypeRepository \ 13 | publishWatchosArm32PublicationToSonatypeRepository \ 14 | publishWatchosArm64PublicationToSonatypeRepository \ 15 | publishWatchosSimulatorArm64PublicationToSonatypeRepository \ 16 | publishWatchosX64PublicationToSonatypeRepository \ 17 | publishWatchosX86PublicationToSonatypeRepository 18 | elif [ "$OS" == "windows-latest" ]; then 19 | ./gradlew publishMingwX64PublicationToSonatypeRepository 20 | elif [ "$OS" == "ubuntu-latest" ]; then 21 | ./gradlew publishToSonatype 22 | else 23 | ./gradlew publishToSonatype 24 | fi -------------------------------------------------------------------------------- /sample/mpp-library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | plugins { 6 | id("kmp-library-convention") 7 | } 8 | 9 | dependencies { 10 | commonTestImplementation(projects.testCore) 11 | } 12 | -------------------------------------------------------------------------------- /sample/mpp-library/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/Greeting.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package com.icerockdev.library 6 | 7 | class Greeting { 8 | fun greet() = println("Hello World!") 9 | } 10 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | enableFeaturePreview("VERSION_CATALOGS") 5 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 6 | 7 | pluginManagement { 8 | repositories { 9 | mavenCentral() 10 | google() 11 | 12 | gradlePluginPortal() 13 | } 14 | } 15 | 16 | dependencyResolutionManagement { 17 | repositories { 18 | mavenCentral() 19 | google() 20 | } 21 | } 22 | 23 | includeBuild("test-build-logic") 24 | 25 | include(":test-core") 26 | include(":test-robolectric") 27 | include(":sample:mpp-library") 28 | -------------------------------------------------------------------------------- /test-build-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | plugins { 6 | `kotlin-dsl` 7 | } 8 | 9 | repositories { 10 | mavenCentral() 11 | google() 12 | gradlePluginPortal() 13 | } 14 | 15 | dependencies { 16 | api(libs.mobileMultiplatformGradlePlugin) 17 | api(libs.kotlinGradlePlugin) 18 | api(libs.androidGradlePlugin) 19 | api(libs.detektGradlePlugin) 20 | } 21 | -------------------------------------------------------------------------------- /test-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | enableFeaturePreview("VERSION_CATALOGS") 6 | 7 | dependencyResolutionManagement { 8 | repositories { 9 | mavenCentral() 10 | google() 11 | } 12 | 13 | versionCatalogs { 14 | create("libs") { 15 | from(files("../gradle/libs.versions.toml")) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test-build-logic/src/main/kotlin/android-app-convention.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | plugins { 6 | id("com.android.application") 7 | id("android-base-convention") 8 | id("org.jetbrains.kotlin.android") 9 | } 10 | 11 | android { 12 | defaultConfig.vectorDrawables.useSupportLibrary = true 13 | 14 | buildTypes { 15 | getByName("release") { 16 | isMinifyEnabled = false 17 | proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") 18 | } 19 | getByName("debug") { 20 | isDebuggable = true 21 | applicationIdSuffix = ".debug" 22 | } 23 | } 24 | 25 | packagingOptions { 26 | exclude("META-INF/*.kotlin_module") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test-build-logic/src/main/kotlin/android-base-convention.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | import com.android.build.gradle.BaseExtension 6 | 7 | configure { 8 | compileSdkVersion(30) 9 | 10 | defaultConfig { 11 | minSdkVersion(16) 12 | targetSdkVersion(30) 13 | } 14 | 15 | with(buildFeatures) { 16 | viewBinding = false 17 | aidl = false 18 | buildConfig = false 19 | prefab = false 20 | compose = false 21 | renderScript = false 22 | resValues = false 23 | shaders = false 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test-build-logic/src/main/kotlin/android-library-convention.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | plugins { 6 | id("com.android.library") 7 | id("android-base-convention") 8 | } 9 | -------------------------------------------------------------------------------- /test-build-logic/src/main/kotlin/detekt-convention.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | import io.gitlab.arturbosch.detekt.Detekt 6 | 7 | plugins { 8 | id("io.gitlab.arturbosch.detekt") 9 | } 10 | 11 | tasks.register("detektWithoutTests") { 12 | group = "verification" 13 | dependsOn(tasks.withType().matching { it.name.contains("Test").not() }) 14 | } 15 | 16 | dependencies { 17 | "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0") 18 | } 19 | -------------------------------------------------------------------------------- /test-build-logic/src/main/kotlin/kmp-library-convention.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | plugins { 6 | id("android-library-convention") 7 | id("org.jetbrains.kotlin.multiplatform") 8 | id("dev.icerock.mobile.multiplatform.android-manifest") 9 | } 10 | 11 | kotlin { 12 | android { 13 | publishAllLibraryVariants() 14 | publishLibraryVariantsGroupedByFlavor = true 15 | } 16 | // JVM 17 | jvm() 18 | // JS 19 | js(IR) { 20 | browser() 21 | nodejs() 22 | } 23 | // linux 24 | linuxX64() 25 | // iOS 26 | iosArm32() 27 | iosArm64() 28 | iosX64() 29 | iosSimulatorArm64() 30 | // macOS 31 | macosArm64() 32 | macosX64() 33 | // watchOS 34 | watchosX64() 35 | watchosX86() 36 | watchosArm32() 37 | watchosArm64() 38 | watchosSimulatorArm64() 39 | // tvOS 40 | tvosArm64() 41 | tvosSimulatorArm64() 42 | tvosX64() 43 | // windows 44 | mingwX64() 45 | 46 | sourceSets { 47 | val commonMain by getting 48 | val nonAndroidMain by creating 49 | val nonAndroidJsMain by creating 50 | nonAndroidMain.dependsOn(commonMain) 51 | nonAndroidJsMain.dependsOn(commonMain) 52 | 53 | listOf( 54 | getByName("iosArm32Main"), 55 | getByName("iosArm64Main"), 56 | getByName("iosX64Main"), 57 | getByName("iosSimulatorArm64Main"), 58 | getByName("macosArm64Main"), 59 | getByName("macosX64Main"), 60 | getByName("watchosX64Main"), 61 | getByName("watchosX86Main"), 62 | getByName("watchosArm32Main"), 63 | getByName("watchosArm64Main"), 64 | getByName("watchosSimulatorArm64Main"), 65 | getByName("tvosArm64Main"), 66 | getByName("tvosSimulatorArm64Main"), 67 | getByName("tvosX64Main"), 68 | getByName("jvmMain"), 69 | getByName("linuxX64Main"), 70 | getByName("mingwX64Main"), 71 | ).forEach { 72 | it.dependsOn(nonAndroidJsMain) 73 | it.dependsOn(nonAndroidMain) 74 | } 75 | 76 | getByName("jsMain").dependsOn(nonAndroidMain) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /test-build-logic/src/main/kotlin/publication-convention.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | import java.util.Base64 6 | 7 | plugins { 8 | id("org.gradle.maven-publish") 9 | id("signing") 10 | } 11 | 12 | publishing { 13 | publications.withType { 14 | // Provide artifacts information requited by Maven Central 15 | pom { 16 | name.set("MOKO test") 17 | description.set("Test utilities for mobile (android & ios) Kotlin Multiplatform development") 18 | url.set("https://github.com/icerockdev/moko-test") 19 | licenses { 20 | license { 21 | name.set("Apache-2.0") 22 | distribution.set("repo") 23 | url.set("https://github.com/icerockdev/moko-test/blob/master/LICENSE.md") 24 | } 25 | } 26 | 27 | developers { 28 | developer { 29 | id.set("Alex009") 30 | name.set("Aleksey Mikhailov") 31 | email.set("aleksey.mikhailov@icerockdev.com") 32 | } 33 | } 34 | 35 | scm { 36 | connection.set("scm:git:ssh://github.com/icerockdev/moko-test.git") 37 | developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-test.git") 38 | url.set("https://github.com/icerockdev/moko-test") 39 | } 40 | } 41 | } 42 | } 43 | 44 | 45 | signing { 46 | val signingKeyId: String? = System.getenv("SIGNING_KEY_ID") 47 | val signingPassword: String? = System.getenv("SIGNING_PASSWORD") 48 | val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key -> 49 | String(Base64.getDecoder().decode(base64Key)) 50 | } 51 | if (signingKeyId != null) { 52 | useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) 53 | sign(publishing.publications) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /test-build-logic/src/main/kotlin/stub-javadoc-convention.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | plugins { 6 | id("org.gradle.maven-publish") 7 | } 8 | 9 | val javadocJar by tasks.registering(Jar::class) { 10 | archiveClassifier.set("javadoc") 11 | } 12 | 13 | publishing { 14 | publications.withType { 15 | // Stub javadoc.jar artifact 16 | artifact(javadocJar.get()) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test-core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | plugins { 5 | id("kmp-library-convention") 6 | id("stub-javadoc-convention") 7 | id("publication-convention") 8 | id("detekt-convention") 9 | } 10 | 11 | dependencies { 12 | commonMainApi(libs.coroutines) 13 | commonMainApi(libs.kotlinTestJUnit) 14 | commonMainApi(libs.coroutinesTest) 15 | 16 | androidMainApi(libs.androidCoreTesting) 17 | } 18 | -------------------------------------------------------------------------------- /test-core/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test-core/src/androidMain/kotlin/dev/icerock/moko/test/AndroidArchitectureInstantTaskExecutorRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import androidx.arch.core.executor.testing.InstantTaskExecutorRule 8 | 9 | actual typealias AndroidArchitectureInstantTaskExecutorRule = InstantTaskExecutorRule 10 | -------------------------------------------------------------------------------- /test-core/src/androidMain/kotlin/dev/icerock/moko/test/TestCoroutineDispatcherRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | actual typealias TestCoroutineDispatcherRule = TestCoroutineRule 8 | -------------------------------------------------------------------------------- /test-core/src/androidMain/kotlin/dev/icerock/moko/test/TestCoroutineRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import kotlinx.coroutines.Dispatchers 8 | import kotlinx.coroutines.ExperimentalCoroutinesApi 9 | import kotlinx.coroutines.test.TestCoroutineDispatcher 10 | import kotlinx.coroutines.test.TestCoroutineScope 11 | import kotlinx.coroutines.test.resetMain 12 | import kotlinx.coroutines.test.setMain 13 | import org.junit.rules.TestRule 14 | import org.junit.runner.Description 15 | import org.junit.runners.model.Statement 16 | 17 | @ExperimentalCoroutinesApi 18 | class TestCoroutineRule : TestRule { 19 | private val testCoroutineDispatcher = TestCoroutineDispatcher() 20 | private val testCoroutineScope = TestCoroutineScope(testCoroutineDispatcher) 21 | 22 | override fun apply(base: Statement, description: Description?) = object : Statement() { 23 | @Throws(Throwable::class) 24 | override fun evaluate() { 25 | Dispatchers.setMain(testCoroutineDispatcher) 26 | 27 | base.evaluate() 28 | 29 | Dispatchers.resetMain() // reset main dispatcher to the original Main dispatcher 30 | testCoroutineScope.cleanupTestCoroutines() 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test-core/src/androidMain/kotlin/dev/icerock/moko/test/TestRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import org.junit.Rule 8 | 9 | actual typealias TestRule = Rule 10 | -------------------------------------------------------------------------------- /test-core/src/androidMain/kotlin/dev/icerock/moko/test/cases/InstantTaskRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test.cases 6 | 7 | import android.annotation.SuppressLint 8 | import androidx.arch.core.executor.ArchTaskExecutor 9 | import androidx.arch.core.executor.TaskExecutor 10 | 11 | // see androidx.arch.core.executor.testing.InstantTaskExecutorRule 12 | @SuppressLint("RestrictedApi") 13 | @Suppress("EmptyDefaultConstructor") 14 | actual class InstantTaskRule actual constructor() : TestCases.Rule { 15 | 16 | override fun setup() { 17 | ArchTaskExecutor.getInstance().setDelegate(object : TaskExecutor() { 18 | override fun executeOnDiskIO(runnable: Runnable) { 19 | runnable.run() 20 | } 21 | 22 | override fun postToMainThread(runnable: Runnable) { 23 | runnable.run() 24 | } 25 | 26 | override fun isMainThread(): Boolean { 27 | return true 28 | } 29 | }) 30 | } 31 | 32 | override fun tearDown() { 33 | ArchTaskExecutor.getInstance().setDelegate(null) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test-core/src/androidMain/kotlin/dev/icerock/moko/test/runBlocking.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import kotlinx.coroutines.CoroutineScope 8 | 9 | @Deprecated( 10 | message = "use runTest start from coroutines-test:1.6.0", 11 | replaceWith = ReplaceWith("runTest", imports = arrayOf("kotlinx.coroutines.test.runTest")) 12 | ) 13 | actual fun runBlocking( 14 | block: suspend CoroutineScope.() -> T 15 | ): T = kotlinx.coroutines.runBlocking(block = block) 16 | -------------------------------------------------------------------------------- /test-core/src/commonMain/kotlin/dev/icerock/moko/test/AndroidArchitectureInstantTaskExecutorRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | @Suppress("EmptyDefaultConstructor") 8 | expect class AndroidArchitectureInstantTaskExecutorRule() 9 | -------------------------------------------------------------------------------- /test-core/src/commonMain/kotlin/dev/icerock/moko/test/CoroutineScopeTestUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import kotlinx.coroutines.CoroutineScope 8 | import kotlinx.coroutines.Job 9 | 10 | fun CoroutineScope.waitChildrenCompletion() = runBlocking { 11 | val job = this@waitChildrenCompletion.coroutineContext[Job] 12 | val children = job?.children.orEmpty().toList() 13 | children.forEach { it.join() } 14 | } 15 | -------------------------------------------------------------------------------- /test-core/src/commonMain/kotlin/dev/icerock/moko/test/TestCoroutineDispatcherRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | @Suppress("EmptyDefaultConstructor") 8 | expect class TestCoroutineDispatcherRule() 9 | -------------------------------------------------------------------------------- /test-core/src/commonMain/kotlin/dev/icerock/moko/test/TestRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | @OptIn(ExperimentalMultiplatform::class) 8 | @OptionalExpectation 9 | expect annotation class TestRule() 10 | -------------------------------------------------------------------------------- /test-core/src/commonMain/kotlin/dev/icerock/moko/test/cases/InstantTaskRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test.cases 6 | 7 | @Suppress("EmptyDefaultConstructor") 8 | expect class InstantTaskRule() : TestCases.Rule 9 | -------------------------------------------------------------------------------- /test-core/src/commonMain/kotlin/dev/icerock/moko/test/cases/TestCases.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test.cases 6 | 7 | import kotlin.test.AfterTest 8 | import kotlin.test.BeforeTest 9 | 10 | abstract class TestCases { 11 | abstract val rules: List 12 | 13 | @BeforeTest 14 | open fun testRulesSetup() { 15 | rules.forEach { it.setup() } 16 | } 17 | 18 | @AfterTest 19 | open fun testRulesTearDown() { 20 | rules.forEach { it.tearDown() } 21 | } 22 | 23 | interface Rule { 24 | fun setup() 25 | fun tearDown() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test-core/src/commonMain/kotlin/dev/icerock/moko/test/runBlocking.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import kotlinx.coroutines.CoroutineScope 8 | 9 | @Deprecated( 10 | message = "use runTest start from coroutines-test:1.6.0", 11 | replaceWith = ReplaceWith("runTest", imports = arrayOf("kotlinx.coroutines.test.runTest")) 12 | ) 13 | expect fun runBlocking( 14 | block: suspend CoroutineScope.() -> T 15 | ): T 16 | -------------------------------------------------------------------------------- /test-core/src/jsMain/kotlin/dev/icerock/moko/test/runBlocking.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import kotlinx.coroutines.CoroutineScope 8 | 9 | @Deprecated( 10 | message = "use runTest start from coroutines-test:1.6.0", 11 | replaceWith = ReplaceWith("runTest", imports = arrayOf("kotlinx.coroutines.test.runTest")) 12 | ) 13 | actual fun runBlocking( 14 | block: suspend CoroutineScope.() -> T 15 | ): T = throw IllegalArgumentException("JS can't have runBlocking. Please use runTest instead") 16 | -------------------------------------------------------------------------------- /test-core/src/nonAndroidJsMain/kotlin/dev/icerock/moko/test/runBlocking.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | import kotlinx.coroutines.CoroutineScope 8 | 9 | @Deprecated( 10 | message = "use runTest start from coroutines-test:1.6.0", 11 | replaceWith = ReplaceWith("runTest", imports = arrayOf("kotlinx.coroutines.test.runTest")) 12 | ) 13 | actual fun runBlocking( 14 | block: suspend CoroutineScope.() -> T 15 | ): T = kotlinx.coroutines.runBlocking(block = block) 16 | -------------------------------------------------------------------------------- /test-core/src/nonAndroidMain/kotlin/dev/icerock/moko/test/AndroidArchitectureInstantTaskExecutorRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | @Suppress("EmptyDefaultConstructor") 8 | actual class AndroidArchitectureInstantTaskExecutorRule actual constructor() 9 | -------------------------------------------------------------------------------- /test-core/src/nonAndroidMain/kotlin/dev/icerock/moko/test/TestCoroutineDispatcherRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test 6 | 7 | @Suppress("EmptyDefaultConstructor") 8 | actual class TestCoroutineDispatcherRule actual constructor() 9 | -------------------------------------------------------------------------------- /test-core/src/nonAndroidMain/kotlin/dev/icerock/moko/test/cases/InstantTaskRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test.cases 6 | 7 | // for ios we should not do anything 8 | @Suppress("EmptyDefaultConstructor") 9 | actual class InstantTaskRule actual constructor() : TestCases.Rule { 10 | 11 | override fun setup() = Unit 12 | 13 | override fun tearDown() = Unit 14 | } 15 | -------------------------------------------------------------------------------- /test-robolectric/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | plugins { 6 | id("kmp-library-convention") 7 | id("stub-javadoc-convention") 8 | id("publication-convention") 9 | id("detekt-convention") 10 | } 11 | 12 | dependencies { 13 | commonMainApi(projects.testCore) 14 | 15 | androidMainApi(libs.robolectric) 16 | } 17 | -------------------------------------------------------------------------------- /test-robolectric/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test-robolectric/src/androidMain/kotlin/dev/icerock/moko/test/robolectric/RobolectricTestCases.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test.robolectric 6 | 7 | import dev.icerock.moko.test.cases.TestCases 8 | import org.junit.runner.RunWith 9 | import org.robolectric.RobolectricTestRunner 10 | 11 | @RunWith(RobolectricTestRunner::class) 12 | actual abstract class RobolectricTestCases : TestCases() 13 | -------------------------------------------------------------------------------- /test-robolectric/src/commonMain/kotlin/dev/icerock/moko/test/robolectric/RobolectricTestCases.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test.robolectric 6 | 7 | import dev.icerock.moko.test.cases.TestCases 8 | 9 | @Suppress("EmptyDefaultConstructor") 10 | expect abstract class RobolectricTestCases() : TestCases 11 | -------------------------------------------------------------------------------- /test-robolectric/src/nonAndroidMain/kotlin/dev/icerock/moko/test/robolectric/RobolectricTestCases.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. 3 | */ 4 | 5 | package dev.icerock.moko.test.robolectric 6 | 7 | import dev.icerock.moko.test.cases.TestCases 8 | 9 | actual abstract class RobolectricTestCases : TestCases() 10 | --------------------------------------------------------------------------------