├── .github └── workflows │ └── master.yml ├── .gitignore ├── LICENSE ├── README.md ├── kotest-allure ├── .editorconfig ├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src │ └── test │ └── kotlin │ └── com │ └── sksamuel │ └── kotest │ └── example │ └── allure │ ├── CubeTest.kt │ ├── MyConfig.kt │ └── SquareTest.kt ├── kotest-javascript ├── .editorconfig ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle │ ├── libs.versions.toml │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src │ ├── jsMain │ └── kotlin │ │ ├── http.kt │ │ └── ssn.kt │ └── jsTest │ └── kotlin │ └── io │ └── kotest │ ├── examples │ └── js │ │ ├── DogTest.kt │ │ ├── ProjectConfig.kt │ │ └── SsnTest.kt │ └── js │ └── config.kt ├── kotest-multiplatform ├── .editorconfig ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle │ ├── libs.versions.toml │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── output.png ├── settings.gradle.kts └── src │ ├── commonMain │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── multiplatform │ │ └── UUID.kt │ ├── commonTest │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── mpp │ │ ├── data │ │ └── DataDrivenTest.kt │ │ └── uuid │ │ └── UUIDTestCommon.kt │ ├── jsMain │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── multiplatform │ │ └── generateUUID.kt │ ├── jsTest │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── mpp │ │ └── UUIDJsTest.kt │ ├── jvmMain │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── multiplatform │ │ └── generateUUID.kt │ ├── jvmTest │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── mpp │ │ └── UUIDJvmTest.kt │ ├── linuxX64Main │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── multiplatform │ │ └── generateUUID.kt │ ├── linuxX64Test │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── mpp │ │ └── UUIDNativeTest.kt │ ├── macosX64Main │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── examples │ │ └── multiplatform │ │ └── generateUUID.kt │ └── mingwX64Main │ └── kotlin │ └── io │ └── kotest │ └── examples │ └── multiplatform │ └── generateUUID.kt ├── kotest-native ├── .editorconfig ├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle │ ├── libs.versions.toml │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src │ ├── desktopMain │ └── kotlin │ │ ├── bits.kt │ │ └── ssn.kt │ └── desktopTest │ └── kotlin │ ├── BitstringTest.kt │ ├── IgnoredTests.kt │ ├── SsnTest.kt │ ├── ThrowableTest.kt │ └── helloworld.kt ├── kotest-spring-webflux ├── .editorconfig ├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle │ ├── libs.versions.toml │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── io │ │ └── kotest │ │ └── example │ │ └── spring │ │ ├── Application.kt │ │ ├── Greeting.kt │ │ ├── GreetingController.kt │ │ └── GreetingService.kt │ └── test │ └── kotlin │ └── io │ └── kotest │ └── example │ └── spring │ └── GreetingControllerTest.kt └── renovate.json /.github/workflows/master.yml: -------------------------------------------------------------------------------- 1 | name: master 2 | 3 | on: 4 | push: 5 | paths-ignore: 6 | - 'doc/**' 7 | - 'documentation/**' 8 | - '*.md' 9 | - '*.yml' 10 | branches: 11 | - master 12 | 13 | jobs: 14 | linux: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout the repo 18 | uses: actions/checkout@v4 19 | with: 20 | fetch-depth: 0 21 | 22 | - name: Setup JDK 23 | uses: actions/setup-java@v4 24 | with: 25 | distribution: 'temurin' 26 | java-version: '17' 27 | 28 | - name: Run tests 29 | run: ./gradlew check 30 | 31 | - name: Bundle the build report 32 | if: failure() 33 | run: find . -type d -name 'reports' | zip -@ -r build-reports.zip 34 | 35 | - name: Upload the build report 36 | if: failure() 37 | uses: actions/upload-artifact@master 38 | with: 39 | name: error-report 40 | path: build-reports.zip 41 | 42 | macos: 43 | runs-on: macos-14 44 | steps: 45 | - name: Checkout the repo 46 | uses: actions/checkout@v4 47 | with: 48 | fetch-depth: 0 49 | 50 | - name: Setup JDK 51 | uses: actions/setup-java@v4 52 | with: 53 | distribution: 'temurin' 54 | java-version: '17' 55 | 56 | - name: Run macos tests 57 | run: ./gradlew macosX64Test 58 | 59 | - name: Bundle the build report 60 | if: failure() 61 | run: find . -type d -name 'reports' | zip -@ -r build-reports.zip 62 | 63 | - name: Upload the build report 64 | if: failure() 65 | uses: actions/upload-artifact@master 66 | with: 67 | name: error-report 68 | path: build-reports.zip 69 | 70 | windows: 71 | runs-on: windows-latest 72 | steps: 73 | - name: Checkout the repo 74 | uses: actions/checkout@v4 75 | with: 76 | fetch-depth: 0 77 | 78 | - name: Setup JDK 79 | uses: actions/setup-java@v4 80 | with: 81 | distribution: 'temurin' 82 | java-version: '17' 83 | 84 | - name: Run tests 85 | run: ./gradlew mingwX64Test 86 | 87 | - name: Bundle the build report 88 | if: failure() 89 | run: find . -type d -name 'reports' | zip -@ -r build-reports.zip 90 | 91 | - name: Upload the build report 92 | if: failure() 93 | uses: actions/upload-artifact@master 94 | with: 95 | name: error-report 96 | path: build-reports.zip 97 | 98 | env: 99 | GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=false -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" 100 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | build/ 8 | .idea/ 9 | .gradle/ 10 | 11 | # Mobile Tools for Java (J2ME) 12 | .mtj.tmp/ 13 | 14 | # Package Files # 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kotest-examples 2 | 3 | This repo contains multiple examples of how to use Kotest. 4 | 5 | ## Projects 6 | 7 | * [Multiplatform](./kotest-multiplatform) — example of a multiplatform project with JVM, JS and native 8 | * [Javscript](./kotest-javascript) — example of a javascript project 9 | * [Spring Webflux](./kotest-spring-webflux) — example of a JVM project using Spring Webflux 10 | * [Allure](./kotest-allure) — example of a JVM project using Allure test reporting 11 | * [Native](./kotest-native) — example of a Kotlin native project -------------------------------------------------------------------------------- /kotest-allure/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | 5 | indent_style = space 6 | indent_size = 3 7 | max_line_length = 120 8 | 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /kotest-allure/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | .allure 25 | -------------------------------------------------------------------------------- /kotest-allure/README.md: -------------------------------------------------------------------------------- 1 | # kotest-allure 2 | 3 | Example project using Kotest and Allure https://github.com/allure-framework 4 | 5 | Clone this repo, execute: 6 | 7 | ``` 8 | ./gradlew check // runs tests 9 | ./gradlew allureReport // generates allure html report 10 | ./gradlew allureServer // launches http server to display html erport 11 | ``` 12 | -------------------------------------------------------------------------------- /kotest-allure/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | kotlin("jvm") version "1.6.21" 5 | id("io.qameta.allure") version "2.10.0" 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | group = "com.example" 13 | version = "0.0.1-SNAPSHOT" 14 | java.sourceCompatibility = JavaVersion.VERSION_1_8 15 | 16 | dependencies { 17 | implementation(kotlin("stdlib")) 18 | implementation(kotlin("reflect")) 19 | testImplementation("io.kotest:kotest-runner-junit5:5.3.2") 20 | testImplementation("io.kotest.extensions:kotest-extensions-allure:1.2.0") 21 | } 22 | 23 | tasks.withType { 24 | useJUnitPlatform() 25 | filter { 26 | isFailOnNoMatchingTests = false 27 | } 28 | } 29 | 30 | allure { 31 | adapter.autoconfigure.set(false) 32 | version.set("2.13.1") 33 | } 34 | 35 | tasks.withType { 36 | kotlinOptions { 37 | freeCompilerArgs = listOf("-Xjsr305=strict") 38 | jvmTarget = "1.8" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /kotest-allure/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotest/kotest-examples/3dc462b8771a12ff34f6cdd5162e0ce9273a0a86/kotest-allure/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kotest-allure/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /kotest-allure/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original 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 POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Stop when "xargs" is not available. 209 | if ! command -v xargs >/dev/null 2>&1 210 | then 211 | die "xargs is not available" 212 | fi 213 | 214 | # Use "xargs" to parse quoted args. 215 | # 216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 217 | # 218 | # In Bash we could simply go: 219 | # 220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 221 | # set -- "${ARGS[@]}" "$@" 222 | # 223 | # but POSIX shell has neither arrays nor command substitution, so instead we 224 | # post-process each arg (as a line of input to sed) to backslash-escape any 225 | # character that might be a shell metacharacter, then use eval to reverse 226 | # that process (while maintaining the separation between arguments), and wrap 227 | # the whole thing up as a single "set" statement. 228 | # 229 | # This will of course break if any of these variables contains a newline or 230 | # an unmatched quote. 231 | # 232 | 233 | eval "set -- $( 234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 235 | xargs -n1 | 236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 237 | tr '\n' ' ' 238 | )" '"$@"' 239 | 240 | exec "$JAVACMD" "$@" 241 | -------------------------------------------------------------------------------- /kotest-allure/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% equ 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% equ 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 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /kotest-allure/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "kotest-examples-allure" 2 | -------------------------------------------------------------------------------- /kotest-allure/src/test/kotlin/com/sksamuel/kotest/example/allure/CubeTest.kt: -------------------------------------------------------------------------------- 1 | package com.sksamuel.kotest.example.allure 2 | 3 | import io.kotest.core.spec.style.DescribeSpec 4 | import io.kotest.matchers.doubles.shouldBeExactly 5 | import kotlin.math.pow 6 | 7 | class CubeTest : DescribeSpec({ 8 | describe("when cubing a number") { 9 | it("should be the cube value") { 10 | 2.0.pow(3.0) shouldBeExactly 8.0 11 | (-4.0).pow(3.0) shouldBeExactly -64.0 12 | 9.0.pow(3.0) shouldBeExactly 729.0 13 | } 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /kotest-allure/src/test/kotlin/com/sksamuel/kotest/example/allure/MyConfig.kt: -------------------------------------------------------------------------------- 1 | package com.sksamuel.kotest.example.allure 2 | 3 | import io.kotest.core.config.AbstractProjectConfig 4 | import io.kotest.extensions.allure.AllureTestReporter 5 | 6 | class MyConfig : AbstractProjectConfig() { 7 | override fun listeners() = listOf(AllureTestReporter()) 8 | } 9 | -------------------------------------------------------------------------------- /kotest-allure/src/test/kotlin/com/sksamuel/kotest/example/allure/SquareTest.kt: -------------------------------------------------------------------------------- 1 | package com.sksamuel.kotest.example.allure 2 | 3 | import io.kotest.core.spec.style.FunSpec 4 | import io.kotest.matchers.doubles.shouldBeExactly 5 | import kotlin.math.pow 6 | 7 | class SquareTest : FunSpec({ 8 | 9 | test("positive square") { 10 | 2.0.pow(2.0) shouldBeExactly 4.0 11 | 4.0.pow(2.0) shouldBeExactly 16.0 12 | 9.0.pow(2.0) shouldBeExactly 81.0 13 | } 14 | 15 | test("negative square") { 16 | (-2.0).pow(2.0) shouldBeExactly 4.0 17 | (-4.0).pow(2.0) shouldBeExactly 16.0 18 | (-9.0).pow(2.0) shouldBeExactly 81.0 19 | } 20 | 21 | }) 22 | 23 | -------------------------------------------------------------------------------- /kotest-javascript/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | 5 | indent_style = space 6 | indent_size = 3 7 | max_line_length = 120 8 | 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /kotest-javascript/README.md: -------------------------------------------------------------------------------- 1 | # kotest-javascript 2 | 3 | A sample javascript project with kotest 4 | -------------------------------------------------------------------------------- /kotest-javascript/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.dsl.KotlinVersion 2 | 3 | plugins { 4 | alias(libs.plugins.kotlin.multiplatform) 5 | alias(libs.plugins.kotest.multiplatform) 6 | } 7 | 8 | repositories { 9 | mavenLocal() 10 | mavenCentral() 11 | maven("https://oss.sonatype.org/content/repositories/snapshots") 12 | } 13 | 14 | kotlin { 15 | js { 16 | browser() 17 | nodejs() 18 | } 19 | compilerOptions { 20 | apiVersion = KotlinVersion.KOTLIN_2_1 21 | languageVersion = KotlinVersion.KOTLIN_2_1 22 | } 23 | sourceSets { 24 | jsMain { 25 | dependencies { 26 | implementation(libs.ktor.client.js) 27 | // needed as a workaround for https://youtrack.jetbrains.com/issue/KT-57235 28 | implementation("org.jetbrains.kotlin:kotlinx-atomicfu-runtime:2.1.10") 29 | } 30 | } 31 | jsTest { 32 | dependencies { 33 | implementation(libs.kotest.assertions.core) 34 | implementation(libs.kotest.framework.engine) 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /kotest-javascript/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.mpp.stability.nowarn=true 2 | kotlin.native.ignoreDisabledTargets=true 3 | kotlin.native.cacheKind=none 4 | -------------------------------------------------------------------------------- /kotest-javascript/gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | kotlin = "2.1.0" 3 | kotest = "6.0.0.M2" 4 | ktor = "3.0.1" 5 | 6 | [libraries] 7 | kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } 8 | kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } 9 | 10 | ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" } 11 | 12 | [plugins] 13 | kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } 14 | kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" } 15 | -------------------------------------------------------------------------------- /kotest-javascript/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotest/kotest-examples/3dc462b8771a12ff34f6cdd5162e0ce9273a0a86/kotest-javascript/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kotest-javascript/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /kotest-javascript/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original 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 POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command; 206 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 207 | # shell script including quotes and variable substitutions, so put them in 208 | # double quotes to make sure that they get re-expanded; and 209 | # * put everything else in single quotes, so that it's not re-expanded. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /kotest-javascript/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 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /kotest-javascript/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | mavenLocal() 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /kotest-javascript/src/jsMain/kotlin/http.kt: -------------------------------------------------------------------------------- 1 | import io.ktor.client.* 2 | import io.ktor.client.engine.js.* 3 | import io.ktor.client.request.* 4 | import io.ktor.client.statement.* 5 | 6 | private val client = HttpClient(Js) 7 | 8 | suspend fun fetchDogUsingHttpClient(): Dog { 9 | val resp = client.get("https://dog.ceo/api/breeds/image/random") 10 | var message = "" 11 | var status = "" 12 | JSON.parse(resp.bodyAsText()) { key, value -> 13 | when (key) { 14 | "message" -> message = value.toString() 15 | "status" -> status = value.toString() 16 | } 17 | } 18 | return Dog(message, status) 19 | } 20 | 21 | data class Dog(val message: String, val status: String) 22 | 23 | -------------------------------------------------------------------------------- /kotest-javascript/src/jsMain/kotlin/ssn.kt: -------------------------------------------------------------------------------- 1 | import kotlin.js.RegExp 2 | 3 | private val socialRegex = RegExp("^\\d{3}-\\d{2}-\\d{4}$") 4 | 5 | fun validateSocial(ssn: String): Boolean { 6 | return socialRegex.test(ssn) && !ssn.contains("0") && !ssn.startsWith("666") 7 | } 8 | -------------------------------------------------------------------------------- /kotest-javascript/src/jsTest/kotlin/io/kotest/examples/js/DogTest.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.js 2 | 3 | import fetchDogUsingHttpClient 4 | import io.kotest.core.spec.style.FunSpec 5 | import io.kotest.matchers.string.shouldEndWith 6 | 7 | class DogTest : FunSpec({ 8 | test("fetching a dog using JS promises") { 9 | fetchDogUsingHttpClient().message.shouldEndWith(".jpg") 10 | } 11 | }) 12 | -------------------------------------------------------------------------------- /kotest-javascript/src/jsTest/kotlin/io/kotest/examples/js/ProjectConfig.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.js 2 | 3 | import io.kotest.core.config.AbstractProjectConfig 4 | 5 | class ProjectConfig : AbstractProjectConfig() { 6 | override suspend fun beforeProject() { 7 | console.log("HELLO!") 8 | } 9 | 10 | override suspend fun afterProject() { 11 | console.log("GOODBYE!") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /kotest-javascript/src/jsTest/kotlin/io/kotest/examples/js/SsnTest.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.js 2 | 3 | import io.kotest.core.spec.style.FunSpec 4 | import io.kotest.matchers.shouldBe 5 | import kotlinx.coroutines.delay 6 | import validateSocial 7 | 8 | class SsnTest : FunSpec({ 9 | 10 | context("js now allows nested tests") { 11 | delay(1000) // look ma, I can use coroutines here ! 12 | context("give me another context!") { 13 | delay(1000) // look ma, I can use coroutines here ! 14 | test("a SSN should be invalid when it contains a zero in any position") { 15 | delay(1000) // look ma, I can use coroutines here too ! 16 | validateSocial("543-23-5013") shouldBe false 17 | validateSocial("043-23-5313") shouldBe false 18 | validateSocial("313-03-5310") shouldBe false 19 | } 20 | } 21 | } 22 | 23 | test("a SSN should be invalid when it starts with 666") { 24 | validateSocial("666-23-1234") shouldBe false 25 | } 26 | 27 | test("a SSN should be in the required format") { 28 | validateSocial("123-45-6789") shouldBe true 29 | validateSocial("123-45-678") shouldBe false 30 | validateSocial("12-45-6789") shouldBe false 31 | validateSocial("1234-56-678") shouldBe false 32 | validateSocial("123456789") shouldBe false 33 | validateSocial("123-456789") shouldBe false 34 | validateSocial("12345-6789") shouldBe false 35 | validateSocial("") shouldBe false 36 | } 37 | 38 | }) 39 | -------------------------------------------------------------------------------- /kotest-javascript/src/jsTest/kotlin/io/kotest/js/config.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.js 2 | 3 | fun config() {} 4 | -------------------------------------------------------------------------------- /kotest-multiplatform/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | 5 | indent_style = space 6 | indent_size = 3 7 | max_line_length = 120 8 | 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | end_of_line = lf 13 | 14 | [*.bat] 15 | end_of_line = crlf 16 | 17 | [*.md] 18 | indent_size = 2 19 | 20 | [*.kt] 21 | ij_kotlin_name_count_to_use_star_import = 99 22 | ij_kotlin_name_count_to_use_star_import_for_members = 99 23 | -------------------------------------------------------------------------------- /kotest-multiplatform/README.md: -------------------------------------------------------------------------------- 1 | # kotest-multiplatform 2 | 3 | This project shows an example project with JVM, JS and native tests all running together with Kotest. 4 | 5 | The project has a naive UUID implementation that is bespoke for each of the platforms, a shared test in `commonTest` 6 | that runs on all platforms, and a individual test per platform which tests the unique properties of that platform's UUID 7 | implementation. 8 | 9 | To run tests: `./gradlew check` 10 | 11 | Results should look something like: 12 | 13 | ![output](output.png) 14 | -------------------------------------------------------------------------------- /kotest-multiplatform/build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | mavenLocal() 5 | } 6 | } 7 | 8 | @Suppress("DSL_SCOPE_VIOLATION") 9 | plugins { 10 | java 11 | id("java-library") 12 | alias(libs.plugins.kotlin.multiplatform) 13 | alias(libs.plugins.kotest.multiplatform) 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | mavenCentral() 19 | mavenLocal() 20 | maven("https://oss.sonatype.org/content/repositories/snapshots") 21 | } 22 | } 23 | 24 | kotlin { 25 | 26 | targets { 27 | jvm { 28 | compilations.all { 29 | kotlinOptions { 30 | jvmTarget = "17" 31 | } 32 | } 33 | } 34 | js(IR) { 35 | browser() 36 | //nodejs() 37 | } 38 | linuxX64() 39 | macosX64() 40 | mingwX64() 41 | } 42 | 43 | targets.all { 44 | compilations.all { 45 | kotlinOptions { 46 | verbose = true 47 | } 48 | } 49 | } 50 | 51 | sourceSets { 52 | 53 | val commonMain by getting { 54 | dependencies { 55 | implementation(libs.kotlinx.coroutines.core) 56 | } 57 | } 58 | 59 | val commonTest by getting { 60 | dependencies { 61 | implementation(libs.kotest.assertions.core) 62 | implementation(libs.kotest.framework.engine) 63 | implementation(libs.kotest.framework.datatest) 64 | implementation(kotlin("test-common")) 65 | implementation(kotlin("test-annotations-common")) 66 | } 67 | } 68 | 69 | val jvmTest by getting { 70 | dependencies { 71 | implementation(libs.kotest.runner.junit5) 72 | } 73 | } 74 | } 75 | } 76 | 77 | tasks.withType().configureEach { 78 | kotlinOptions { 79 | languageVersion = "1.9" 80 | apiVersion = "1.9" 81 | } 82 | } 83 | 84 | tasks.named("jvmTest") { 85 | useJUnitPlatform() 86 | filter { 87 | isFailOnNoMatchingTests = false 88 | } 89 | testLogging { 90 | showExceptions = true 91 | showStandardStreams = true 92 | events = setOf( 93 | org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED, 94 | org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED 95 | ) 96 | exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /kotest-multiplatform/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.mpp.stability.nowarn=true 2 | kotlin.native.ignoreDisabledTargets=true 3 | kotlin.native.cacheKind=none 4 | -------------------------------------------------------------------------------- /kotest-multiplatform/gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | kotlin = "1.9.23" 3 | coroutines = "1.7.1" 4 | kotest = "5.9.1" 5 | 6 | [libraries] 7 | kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } 8 | kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } 9 | kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" } 10 | kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } 11 | 12 | kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } 13 | 14 | [plugins] 15 | kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } 16 | kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" } 17 | -------------------------------------------------------------------------------- /kotest-multiplatform/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotest/kotest-examples/3dc462b8771a12ff34f6cdd5162e0ce9273a0a86/kotest-multiplatform/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kotest-multiplatform/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /kotest-multiplatform/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original 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 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /kotest-multiplatform/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 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /kotest-multiplatform/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotest/kotest-examples/3dc462b8771a12ff34f6cdd5162e0ce9273a0a86/kotest-multiplatform/output.png -------------------------------------------------------------------------------- /kotest-multiplatform/settings.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotest/kotest-examples/3dc462b8771a12ff34f6cdd5162e0ce9273a0a86/kotest-multiplatform/settings.gradle.kts -------------------------------------------------------------------------------- /kotest-multiplatform/src/commonMain/kotlin/io/kotest/examples/multiplatform/UUID.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.multiplatform 2 | 3 | /** 4 | * This is a UUID struct, but the implementations that generate the uuids are located 5 | * in the target specific source sets. 6 | */ 7 | data class UUID(val value: String) 8 | 9 | expect fun generateUUID(): UUID -------------------------------------------------------------------------------- /kotest-multiplatform/src/commonTest/kotlin/io/kotest/examples/mpp/data/DataDrivenTest.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.mpp.data 2 | 3 | import io.kotest.core.spec.style.FunSpec 4 | import io.kotest.datatest.withData 5 | import io.kotest.matchers.shouldBe 6 | 7 | class DataDrivenTest : FunSpec() { 8 | init { 9 | withData( 10 | PythagTriple(3, 4, 5), 11 | PythagTriple(6, 8, 10), 12 | ) { (a, b, c) -> 13 | a * a + b * b shouldBe c * c 14 | } 15 | } 16 | } 17 | 18 | data class PythagTriple(val a: Int, val b: Int, val c: Int) 19 | -------------------------------------------------------------------------------- /kotest-multiplatform/src/commonTest/kotlin/io/kotest/examples/mpp/uuid/UUIDTestCommon.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.mpp.uuid 2 | 3 | import io.kotest.core.spec.style.FunSpec 4 | import io.kotest.examples.multiplatform.generateUUID 5 | import io.kotest.matchers.collections.shouldHaveSize 6 | 7 | class UUIDTestCommon : FunSpec() { 8 | init { 9 | test("uuids should be somewhat unique!") { 10 | List(100) { generateUUID() }.toSet().shouldHaveSize(100) 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /kotest-multiplatform/src/jsMain/kotlin/io/kotest/examples/multiplatform/generateUUID.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.multiplatform 2 | 3 | import kotlin.js.Date 4 | import kotlin.random.Random 5 | 6 | actual fun generateUUID(): UUID { 7 | // this is not meant to be a high quality uuid, just showing the principal of each platform 8 | // having its own implementation 9 | return UUID(Date().getTime().toString() + Random.nextInt(10000000, 99999999).toString()) 10 | } -------------------------------------------------------------------------------- /kotest-multiplatform/src/jsTest/kotlin/io/kotest/examples/mpp/UUIDJsTest.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.mpp 2 | 3 | import io.kotest.core.spec.style.FunSpec 4 | import io.kotest.examples.multiplatform.generateUUID 5 | import io.kotest.matchers.string.shouldHaveLength 6 | 7 | // this test only runs for JS implementations 8 | class UUIDJsTest : FunSpec() { 9 | init { 10 | test("uuids should have length 21") { 11 | generateUUID().value.shouldHaveLength(21) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /kotest-multiplatform/src/jvmMain/kotlin/io/kotest/examples/multiplatform/generateUUID.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.multiplatform 2 | 3 | actual fun generateUUID(): UUID { 4 | return UUID(java.util.UUID.randomUUID().toString()) 5 | } -------------------------------------------------------------------------------- /kotest-multiplatform/src/jvmTest/kotlin/io/kotest/examples/mpp/UUIDJvmTest.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.mpp 2 | 3 | import io.kotest.core.spec.style.FunSpec 4 | import io.kotest.examples.multiplatform.generateUUID 5 | import io.kotest.matchers.string.shouldHaveLength 6 | 7 | // this test only runs for JVM implementations 8 | class UUIDJvmTest : FunSpec() { 9 | init { 10 | test("uuids should be in be type 4 format") { 11 | generateUUID().value.shouldHaveLength(36) 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /kotest-multiplatform/src/linuxX64Main/kotlin/io/kotest/examples/multiplatform/generateUUID.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.multiplatform 2 | 3 | import kotlin.random.Random 4 | import kotlin.system.getTimeNanos 5 | 6 | actual fun generateUUID(): UUID { 7 | // this is not meant to be a high quality uuid, just showing the principal of each platform 8 | // having its own implementation 9 | return UUID(getTimeNanos().toString().padStart(20, '0') + Random.nextInt(10000000, 99999999).toString()) 10 | } 11 | -------------------------------------------------------------------------------- /kotest-multiplatform/src/linuxX64Test/kotlin/io/kotest/examples/mpp/UUIDNativeTest.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.mpp 2 | 3 | import io.kotest.core.spec.style.FunSpec 4 | import io.kotest.examples.multiplatform.generateUUID 5 | import io.kotest.matchers.string.shouldHaveLength 6 | 7 | // this test only runs for native implementations 8 | class UUIDNativeTest : FunSpec() { 9 | init { 10 | test("uuids should have length 28") { 11 | generateUUID().value.shouldHaveLength(28) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /kotest-multiplatform/src/macosX64Main/kotlin/io/kotest/examples/multiplatform/generateUUID.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.multiplatform 2 | 3 | import kotlin.random.Random 4 | import kotlin.system.getTimeNanos 5 | 6 | actual fun generateUUID(): UUID { 7 | // this is not meant to be a high quality uuid, just showing the principal of each platform 8 | // having its own implementation 9 | return UUID(getTimeNanos().toString() + Random.nextInt(10000000, 99999999).toString()) 10 | } -------------------------------------------------------------------------------- /kotest-multiplatform/src/mingwX64Main/kotlin/io/kotest/examples/multiplatform/generateUUID.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.examples.multiplatform 2 | 3 | import kotlin.random.Random 4 | import kotlin.system.getTimeNanos 5 | 6 | actual fun generateUUID(): UUID { 7 | // this is not meant to be a high quality uuid, just showing the principal of each platform 8 | // having its own implementation 9 | return UUID(getTimeNanos().toString() + Random.nextInt(10000000, 99999999).toString()) 10 | } -------------------------------------------------------------------------------- /kotest-native/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | 5 | indent_style = space 6 | indent_size = 3 7 | max_line_length = 120 8 | 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /kotest-native/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | .allure 12 | 13 | *.iml 14 | .idea 15 | 16 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 17 | hs_err_pid* 18 | out/ 19 | 20 | build 21 | target 22 | .idea 23 | .gradle 24 | 25 | allure-results/ 26 | 27 | # Gradle wrapper 28 | !gradle/wrapper/gradle-wrapper.jar 29 | 30 | allure.log 31 | kotest.log 32 | kotest-tests-junit-report.log 33 | kotest-tests-core.log 34 | 35 | local.properties 36 | .kotest 37 | /kotest-examples/kotest-examples-javascript/node_modules/ 38 | *.gpg.enc 39 | 40 | kotest-tests/kotest-tests-js/node_modules/ 41 | .DS_Store 42 | -------------------------------------------------------------------------------- /kotest-native/README.md: -------------------------------------------------------------------------------- 1 | # kotest-native 2 | 3 | Example project showing how to use Kotest for native targets 4 | -------------------------------------------------------------------------------- /kotest-native/build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | mavenLocal() 5 | } 6 | } 7 | 8 | @Suppress("DSL_SCOPE_VIOLATION") 9 | plugins { 10 | alias(libs.plugins.kotlin.multiplatform) 11 | alias(libs.plugins.kotest.multiplatform) 12 | } 13 | 14 | repositories { 15 | mavenCentral() 16 | mavenLocal() 17 | maven("https://oss.sonatype.org/content/repositories/snapshots") 18 | } 19 | 20 | kotlin { 21 | 22 | targets { 23 | linuxX64 { 24 | binaries { 25 | executable() 26 | } 27 | } 28 | 29 | mingwX64() 30 | 31 | macosX64() 32 | macosArm64() 33 | 34 | tvos() 35 | tvosSimulatorArm64() 36 | 37 | watchosArm32() 38 | watchosArm64() 39 | watchosX86() 40 | watchosX64() 41 | watchosSimulatorArm64() 42 | 43 | iosX64() 44 | iosArm64() 45 | iosArm32() 46 | iosSimulatorArm64() 47 | } 48 | 49 | sourceSets { 50 | 51 | val commonMain by getting 52 | val commonTest by getting { 53 | dependencies { 54 | implementation(kotlin("test-common")) 55 | implementation(kotlin("test-annotations-common")) 56 | implementation(libs.kotlinx.coroutines.core) 57 | implementation(libs.kotest.framework.engine) 58 | } 59 | } 60 | 61 | val desktopMain by creating { 62 | dependsOn(commonMain) 63 | dependencies { 64 | implementation(kotlin("native-utils")) 65 | } 66 | } 67 | 68 | val linuxX64Main by getting { 69 | dependsOn(desktopMain) 70 | } 71 | 72 | val desktopTest by creating { 73 | dependsOn(commonTest) 74 | } 75 | 76 | val linuxX64Test by getting { 77 | dependsOn(desktopTest) 78 | } 79 | 80 | val macosArm64Main by getting { 81 | dependsOn(desktopMain) 82 | } 83 | 84 | val macosArm64Test by getting { 85 | dependsOn(desktopTest) 86 | } 87 | } 88 | } 89 | 90 | tasks.withType().configureEach { 91 | kotlinOptions { 92 | apiVersion = "1.6" 93 | verbose = true 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /kotest-native/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.mpp.stability.nowarn=true 2 | org.gradle.jvmargs=-Xmx3G -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 3 | -------------------------------------------------------------------------------- /kotest-native/gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | kotest = "5.4.2" 3 | kotlin = "1.6.21" 4 | coroutines = "1.6.4" 5 | 6 | [libraries] 7 | kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } 8 | 9 | kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } 10 | 11 | [plugins] 12 | kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" } 13 | kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } 14 | -------------------------------------------------------------------------------- /kotest-native/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotest/kotest-examples/3dc462b8771a12ff34f6cdd5162e0ce9273a0a86/kotest-native/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kotest-native/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /kotest-native/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original 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 POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /kotest-native/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 | -------------------------------------------------------------------------------- /kotest-native/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | if (File("../kotest").exists() && System.getenv("NO_INCLUDE") == null) { 2 | println("w: Including Kotest build, will substitute all Kotest stuff for currently checked out implementations") 3 | includeBuild("../kotest") 4 | } 5 | -------------------------------------------------------------------------------- /kotest-native/src/desktopMain/kotlin/bits.kt: -------------------------------------------------------------------------------- 1 | fun bitstring(bits: List): String { 2 | require(bits.isNotEmpty()) 3 | return buildString { 4 | repeat(bits.size) { 5 | if (bits[it]) append("1") else append("0") 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /kotest-native/src/desktopMain/kotlin/ssn.kt: -------------------------------------------------------------------------------- 1 | private val socialRegex = "^\\d{3}-\\d{2}-\\d{4}$".toRegex() 2 | 3 | fun validateSocial(ssn: String): Boolean { 4 | return socialRegex.matches(ssn) && !ssn.contains("0") && !ssn.startsWith("666") 5 | } 6 | -------------------------------------------------------------------------------- /kotest-native/src/desktopTest/kotlin/BitstringTest.kt: -------------------------------------------------------------------------------- 1 | import io.kotest.assertions.throwables.shouldThrowAny 2 | import io.kotest.core.spec.style.DescribeSpec 3 | import io.kotest.matchers.shouldBe 4 | 5 | class BitstringTest : DescribeSpec() { 6 | init { 7 | describe("bit strings") { 8 | it("should set bits based on booleans 1") { 9 | bitstring(listOf(true, false, true, false, true)) shouldBe "10101" 10 | bitstring(listOf(false, false, false, false, false, false, false, true)) shouldBe "00000001" 11 | } 12 | it("should error on empty") { 13 | shouldThrowAny { 14 | bitstring(listOf()) 15 | } 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /kotest-native/src/desktopTest/kotlin/IgnoredTests.kt: -------------------------------------------------------------------------------- 1 | import io.kotest.core.spec.style.ShouldSpec 2 | import io.kotest.matchers.shouldBe 3 | 4 | class IgnoredTests : ShouldSpec() { 5 | init { 6 | xshould("ignored by x method") { 7 | 1 shouldBe 2 8 | } 9 | should("ignored by config").config(enabled = false) { 10 | "a" shouldBe "b" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /kotest-native/src/desktopTest/kotlin/SsnTest.kt: -------------------------------------------------------------------------------- 1 | import io.kotest.core.spec.style.FunSpec 2 | import io.kotest.matchers.shouldBe 3 | 4 | class SsnTest : FunSpec() { 5 | init { 6 | 7 | test("ssn should be invalid when it contains a zero ") { 8 | validateSocial("543-23-5013") shouldBe false 9 | validateSocial("043-23-5313") shouldBe false 10 | validateSocial("313-03-5310") shouldBe false 11 | } 12 | 13 | test("SSN should be invalid when it starts with 666 ") { 14 | validateSocial("666-23-1234") shouldBe false 15 | } 16 | 17 | test("ssn should be in the accepted format") { 18 | validateSocial("") shouldBe false 19 | validateSocial("123-45-678") shouldBe false 20 | validateSocial("12-45-6789") shouldBe false 21 | validateSocial("1234-56-678") shouldBe false 22 | validateSocial("123456789") shouldBe false 23 | validateSocial("123-456789") shouldBe false 24 | validateSocial("12345-6789") shouldBe false 25 | validateSocial("") shouldBe false 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /kotest-native/src/desktopTest/kotlin/ThrowableTest.kt: -------------------------------------------------------------------------------- 1 | import io.kotest.assertions.throwables.shouldThrow 2 | import io.kotest.assertions.throwables.shouldThrowAny 3 | import io.kotest.core.spec.style.ShouldSpec 4 | 5 | class ThrowableTest : ShouldSpec() { 6 | init { 7 | should("support shouldThrow") { 8 | shouldThrow { 9 | error("foo") 10 | } 11 | } 12 | 13 | should("support shouldThrowAny") { 14 | shouldThrowAny { 15 | error("foo") 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /kotest-native/src/desktopTest/kotlin/helloworld.kt: -------------------------------------------------------------------------------- 1 | import io.kotest.core.spec.style.ShouldSpec 2 | import io.kotest.matchers.shouldBe 3 | 4 | class HelloWorldTest : ShouldSpec({ 5 | should("be able to do arithmetic") { 6 | (1+2) shouldBe 3 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /kotest-spring-webflux/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | 5 | indent_style = space 6 | indent_size = 3 7 | max_line_length = 120 8 | 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /kotest-spring-webflux/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | 34 | .DS_Store 35 | -------------------------------------------------------------------------------- /kotest-spring-webflux/README.md: -------------------------------------------------------------------------------- 1 | # kotest-spring-webflux 2 | 3 | Example project using kotest and spring webflux 4 | -------------------------------------------------------------------------------- /kotest-spring-webflux/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | @Suppress("DSL_SCOPE_VIOLATION") 4 | plugins { 5 | id("org.springframework.boot") version "2.7.5" 6 | alias(libs.plugins.kotlin.jvm) 7 | alias(libs.plugins.kotlin.plugin.spring) 8 | } 9 | 10 | apply(plugin = "io.spring.dependency-management") 11 | 12 | repositories { 13 | mavenCentral() 14 | } 15 | 16 | group = "com.example" 17 | version = "0.0.1-SNAPSHOT" 18 | java.sourceCompatibility = JavaVersion.VERSION_1_8 19 | 20 | extra["kotlinx-coroutines.version"] = "1.6.2" 21 | 22 | dependencies { 23 | implementation(kotlin("reflect")) 24 | implementation(libs.spring.boot.starter.webflux) 25 | implementation(libs.jackson.module.kotlin) 26 | implementation(libs.reactor.kotlin.extensions) 27 | implementation(libs.kotlinx.coroutines.reactor) 28 | 29 | testImplementation(libs.springmockk) 30 | testImplementation(libs.kotest.runner.junit5) 31 | testImplementation(libs.kotest.extensions.spring) 32 | testImplementation(libs.reactor.test) 33 | testImplementation(libs.spring.boot.starter.test) { 34 | exclude(group = "org.junit.vintage", module = "junit-vintage-engine") 35 | exclude(module = "mockito-core") 36 | } 37 | } 38 | 39 | tasks.withType { 40 | useJUnitPlatform() 41 | filter { 42 | isFailOnNoMatchingTests = false 43 | } 44 | } 45 | 46 | tasks.withType { 47 | kotlinOptions { 48 | freeCompilerArgs = listOf("-Xjsr305=strict") 49 | jvmTarget = "1.8" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /kotest-spring-webflux/gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | kotlin = "1.6.21" 3 | kotest = "5.4.2" 4 | 5 | [libraries] 6 | kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } 7 | kotest-extensions-spring = { module = "io.kotest.extensions:kotest-extensions-spring", version = "1.1.2" } 8 | springmockk = { module = "com.ninja-squad:springmockk", version = "3.1.1" } 9 | 10 | # Versions managed by Spring dependency management, and thus excluded here 11 | kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor" } 12 | reactor-kotlin-extensions = { module = "io.projectreactor.kotlin:reactor-kotlin-extensions" } 13 | reactor-test = { module = "io.projectreactor:reactor-test" } 14 | 15 | spring-boot-starter-webflux = { module = "org.springframework.boot:spring-boot-starter-webflux" } 16 | spring-boot-starter-test = { module = "org.springframework.boot:spring-boot-starter-test" } 17 | jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin" } 18 | 19 | [plugins] 20 | kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } 21 | kotlin-plugin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } 22 | -------------------------------------------------------------------------------- /kotest-spring-webflux/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotest/kotest-examples/3dc462b8771a12ff34f6cdd5162e0ce9273a0a86/kotest-spring-webflux/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kotest-spring-webflux/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /kotest-spring-webflux/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original 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 POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Stop when "xargs" is not available. 209 | if ! command -v xargs >/dev/null 2>&1 210 | then 211 | die "xargs is not available" 212 | fi 213 | 214 | # Use "xargs" to parse quoted args. 215 | # 216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 217 | # 218 | # In Bash we could simply go: 219 | # 220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 221 | # set -- "${ARGS[@]}" "$@" 222 | # 223 | # but POSIX shell has neither arrays nor command substitution, so instead we 224 | # post-process each arg (as a line of input to sed) to backslash-escape any 225 | # character that might be a shell metacharacter, then use eval to reverse 226 | # that process (while maintaining the separation between arguments), and wrap 227 | # the whole thing up as a single "set" statement. 228 | # 229 | # This will of course break if any of these variables contains a newline or 230 | # an unmatched quote. 231 | # 232 | 233 | eval "set -- $( 234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 235 | xargs -n1 | 236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 237 | tr '\n' ' ' 238 | )" '"$@"' 239 | 240 | exec "$JAVACMD" "$@" 241 | -------------------------------------------------------------------------------- /kotest-spring-webflux/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% equ 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% equ 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 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /kotest-spring-webflux/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "kotest-examples-spring-webflux" 2 | -------------------------------------------------------------------------------- /kotest-spring-webflux/src/main/kotlin/io/kotest/example/spring/Application.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.example.spring 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class Application 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /kotest-spring-webflux/src/main/kotlin/io/kotest/example/spring/Greeting.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.example.spring 2 | 3 | data class Greeting(val message: String) 4 | -------------------------------------------------------------------------------- /kotest-spring-webflux/src/main/kotlin/io/kotest/example/spring/GreetingController.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.example.spring 2 | 3 | import org.springframework.http.ResponseEntity 4 | import org.springframework.web.bind.annotation.GetMapping 5 | import org.springframework.web.bind.annotation.PathVariable 6 | import org.springframework.web.bind.annotation.RestController 7 | import reactor.core.publisher.Mono 8 | 9 | 10 | @RestController 11 | class GreetingController(private val greetingService: GreetingService) { 12 | 13 | @GetMapping("/greet/{name}") 14 | fun greet(@PathVariable name: String): Mono> { 15 | val defaultGreeting = Greeting("This is default greeting.") 16 | 17 | return greetingService.greetingFor(name) 18 | .map { ResponseEntity.ok(it) } 19 | .onErrorReturn(ResponseEntity.ok(defaultGreeting)) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /kotest-spring-webflux/src/main/kotlin/io/kotest/example/spring/GreetingService.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.example.spring 2 | 3 | import org.springframework.stereotype.Component 4 | import reactor.core.publisher.Mono 5 | 6 | @Component 7 | class GreetingService { 8 | fun greetingFor(name: String): Mono { 9 | return Mono.just(Greeting("Welcome $name")) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /kotest-spring-webflux/src/test/kotlin/io/kotest/example/spring/GreetingControllerTest.kt: -------------------------------------------------------------------------------- 1 | package io.kotest.example.spring 2 | 3 | import com.ninjasquad.springmockk.MockkBean 4 | import io.kotest.core.spec.style.StringSpec 5 | import io.mockk.every 6 | import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient 7 | import org.springframework.boot.test.context.SpringBootTest 8 | import org.springframework.test.web.reactive.server.WebTestClient 9 | import org.springframework.test.web.reactive.server.expectBody 10 | import reactor.core.publisher.Mono 11 | 12 | @SpringBootTest 13 | @AutoConfigureWebTestClient 14 | class GreetingControllerUnitTest( 15 | @MockkBean private val greetingService: GreetingService, 16 | private val webTestClient: WebTestClient 17 | ) : StringSpec({ 18 | 19 | "should return the greeting provided by greeting service" { 20 | val greeting = Greeting("Welcome someone") 21 | 22 | every { greetingService.greetingFor("someone") } returns Mono.just(greeting) 23 | 24 | webTestClient 25 | .get() 26 | .uri("/greet/someone") 27 | .exchange() 28 | .expectStatus().isOk 29 | .expectBody().isEqualTo(greeting) 30 | } 31 | 32 | "should return a default greeting when greeting service return error" { 33 | val defaultGreeting = Greeting("This is default greeting.") 34 | 35 | every { greetingService.greetingFor("someone") } returns Mono.error(RuntimeException("Boom Boom!")) 36 | 37 | webTestClient 38 | .get() 39 | .uri("/greet/someone") 40 | .exchange() 41 | .expectStatus().isOk 42 | .expectBody().isEqualTo(defaultGreeting) 43 | } 44 | }) 45 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", "github>kotest/renovate-config" 4 | ] 5 | } 6 | --------------------------------------------------------------------------------