├── .circleci └── config.yml ├── .editorconfig ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml ├── settings.xml └── src └── main └── kotlin └── com └── acomodeo └── kotlintest └── spring ├── SpringBehaviorSpec.kt ├── SpringFeatureSpec.kt ├── SpringFreeSpec.kt ├── SpringFunSpec.kt ├── SpringShouldSpec.kt ├── SpringSpec.kt ├── SpringStringSpec.kt ├── SpringWordSpec.kt ├── annotation ├── EnableKotlinTest.kt └── KotlinTestConfiguration.kt ├── runner └── KotlinTestSpringRunner.kt └── util └── AutowireCapableBeanFactoryHolder.kt /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | jobs: 4 | build: 5 | docker: 6 | - image: openjdk 7 | command: [ /bin/sh ] 8 | 9 | working_directory: /kotlintest-spring 10 | 11 | steps: 12 | - checkout 13 | - restore_cache: 14 | keys: 15 | - kotlintest-spring-{{ .Branch }}-{{ checksum "pom.xml" }} 16 | - kotlintest-spring-master-{{ checksum "pom.xml" }} 17 | - kotlintest-spring-{{ .Branch }} 18 | - kotlintest-spring-master 19 | - run: 20 | command: | 21 | ./mvnw -B versions:set -DnewVersion=${CIRCLE_BRANCH}-SNAPSHOT 22 | ./mvnw -B -s settings.xml -U clean deploy 23 | - save_cache: 24 | key: kotlintest-spring-{{ .Branch }}-{{ checksum "pom.xml" }} 25 | paths: 26 | - ~/.m2 27 | - store_test_results: 28 | path: /kotlintest-spring/target/surefire-reports 29 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | max_line_length = 100 11 | 12 | [*.{kt,kts}] 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | max_line_length = 100 16 | 17 | [*.md] 18 | trim_trailing_whitespace = false 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### JetBrains template 3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 5 | .idea/ 6 | 7 | .DS_Store 8 | 9 | ## File-based project format: 10 | *.iws 11 | 12 | ## Plugin-specific files: 13 | 14 | # IntelliJ 15 | /out/ 16 | 17 | # mpeltonen/sbt-idea plugin 18 | .idea_modules/ 19 | 20 | *.iml 21 | 22 | # JIRA plugin 23 | atlassian-ide-plugin.xml 24 | 25 | # Crashlytics plugin (for Android Studio and IntelliJ) 26 | com_crashlytics_export_strings.xml 27 | crashlytics.properties 28 | crashlytics-build.properties 29 | fabric.properties 30 | ### Java template 31 | *.class 32 | 33 | # Mobile Tools for Java (J2ME) 34 | .mtj.tmp/ 35 | 36 | # Package Files # 37 | ### Maven template 38 | target/ 39 | pom.xml.tag 40 | pom.xml.releaseBackup 41 | pom.xml.versionsBackup 42 | pom.xml.next 43 | release.properties 44 | dependency-reduced-pom.xml 45 | buildNumber.properties 46 | .mvn/timing.properties 47 | 48 | !.mvn/wrapper/maven-wrapper.jar 49 | *.war 50 | *.ear 51 | 52 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 53 | hs_err_pid* 54 | 55 | *.sql 56 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Acomodeo/kotlintest-spring/1b7593406c66ae42992b6ba3674e36cabc4d57ce/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Acomodeo UG 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated 2 | The core team of kotlintest included the functionality in thin package in their core code. 3 | Look at https://github.com/kotlintest/kotlintest/blob/master/doc/reference.md#spring on how to use their conectors. 4 | This code is not maintained right now because of this. 5 | 6 | # kotlintest-spring 7 | A module that allows kotlintest to work together with spring 8 | 9 | ## How it works 10 | Basically, we wrote our own runner that first starts the Spring Runner and then executes the Kotlin Test runner. 11 | 12 | Sadly, the Spring Runner delegates to a JUnit Runner which throws an Exception if there are no JUnit tests in the class. 13 | That's why we added our own test that does nothing (currently called "loading"). 14 | 15 | In addition to that we enabled autowiring for the kotlin test spec classes by overwriting the beforeAll method and using a 16 | static class to access the AutowireCapableBeanFactory. 17 | 18 | ## What do I need to do? 19 | Instead of extending the normal *Spec classes you need to extend the Spring*Spec classes. 20 | 21 | You also need to add the @EnableKotlinTest annotation to your test context in order for the static utility class to be 22 | picked up. 23 | 24 | ## Download 25 | 26 | Just use https://jitpack.io to download this project and depend on it with Maven or Gradle 27 | 28 | ``` 29 | 30 | 31 | true 32 | 33 | jitpack.io 34 | https://jitpack.io 35 | 36 | ``` 37 | 38 | And then add the dependency: 39 | 40 | ``` 41 | 42 | com.acomodeo 43 | kotlintest-spring 44 | master-SNAPSHOT 45 | test 46 | 47 | ``` 48 | 49 | ## Versioning 50 | 51 | Internally we always use the master branch version of all libraries. This is reflected here. The library will always be backwards compatible. 52 | If you do not want to "auto" update the library, feel free to just depend on a certain commit hash. 53 | 54 | ## License 55 | 56 | For License information see the file LICENSE 57 | 58 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | if [ "$MVNW_VERBOSE" = true ]; then 205 | echo $MAVEN_PROJECTBASEDIR 206 | fi 207 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 208 | 209 | # For Cygwin, switch paths to Windows format before running java 210 | if $cygwin; then 211 | [ -n "$M2_HOME" ] && 212 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 213 | [ -n "$JAVA_HOME" ] && 214 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 215 | [ -n "$CLASSPATH" ] && 216 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 217 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 218 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 219 | fi 220 | 221 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 222 | 223 | exec "$JAVACMD" \ 224 | $MAVEN_OPTS \ 225 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 226 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 227 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 228 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 125 | if ERRORLEVEL 1 goto error 126 | goto end 127 | 128 | :error 129 | set ERROR_CODE=1 130 | 131 | :end 132 | @endlocal & set ERROR_CODE=%ERROR_CODE% 133 | 134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 138 | :skipRcPost 139 | 140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 142 | 143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 144 | 145 | exit /B %ERROR_CODE% 146 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | com.acomodeo 7 | kotlintest-spring 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | kotlintest-spring 12 | 13 | 14 | UTF-8 15 | 1.2.21 16 | 4.12 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-parent 22 | 1.5.10.RELEASE 23 | 24 | 25 | 26 | 27 | 28 | storage-bin 29 | https://storage-bin.acomodeo.build/artifactory/public 30 | 31 | 32 | storage-bin 33 | https://storage-bin.acomodeo.build/artifactory/public 34 | 35 | 36 | 37 | 38 | 39 | 40 | true 41 | 42 | central 43 | https://jcenter.bintray.com 44 | 45 | 46 | 47 | 48 | central 49 | bintray 50 | https://jcenter.bintray.com 51 | 52 | 53 | 54 | true 55 | 56 | jitpack.io 57 | https://jitpack.io 58 | 59 | 60 | 61 | 62 | 63 | org.jetbrains.kotlin 64 | kotlin-stdlib 65 | ${kotlin.version} 66 | 67 | 68 | org.jetbrains.kotlin 69 | kotlin-reflect 70 | ${kotlin.version} 71 | 72 | 73 | io.kotlintest 74 | kotlintest 75 | 2.0.7 76 | 77 | 78 | junit 79 | junit 80 | 81 | 82 | org.springframework 83 | spring-test 84 | 85 | 86 | org.springframework 87 | spring-context 88 | 89 | 90 | 91 | 92 | src/main/kotlin 93 | src/test/kotlin 94 | 95 | 96 | 97 | org.jetbrains.kotlin 98 | kotlin-maven-plugin 99 | ${kotlin.version} 100 | 101 | 102 | compile 103 | compile 104 | 105 | compile 106 | 107 | 108 | 109 | test-compile 110 | test-compile 111 | 112 | test-compile 113 | 114 | 115 | 116 | 117 | 118 | org.apache.maven.plugins 119 | maven-antrun-plugin 120 | 1.8 121 | false 122 | 123 | 124 | ktlint 125 | process-sources 126 | 127 | 128 | 132 | 133 | 134 | 135 | 136 | 137 | run 138 | 139 | 140 | 141 | 142 | 143 | com.github.shyiko 144 | ktlint 145 | 0.16.0 146 | 147 | 148 | com.github.mhlz 149 | ktlint-rules 150 | master-SNAPSHOT 151 | 152 | 153 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | storage-bin 10 | circleci 11 | ${env.STORAGE_BIN_PASSWORD} 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringBehaviorSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.runner.KotlinTestSpringRunner 4 | import io.kotlintest.Spec 5 | import io.kotlintest.specs.BehaviorSpec 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * @author Mischa Holz 11 | */ 12 | @RunWith(KotlinTestSpringRunner::class) 13 | @Deprecated("The core team of kotlintest wrote their own connector") 14 | abstract class SpringBehaviorSpec : BehaviorSpec(), SpringSpec { 15 | 16 | override val oneInstancePerTest: Boolean = false 17 | 18 | final override fun interceptSpec(context: Spec, spec: () -> Unit) { 19 | autowireAndBeforeAll() 20 | 21 | spec() 22 | } 23 | 24 | @Test 25 | fun loading() { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringFeatureSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.runner.KotlinTestSpringRunner 4 | import io.kotlintest.Spec 5 | import io.kotlintest.specs.FeatureSpec 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * @author Mischa Holz 11 | */ 12 | @RunWith(KotlinTestSpringRunner::class) 13 | @Deprecated("The core team of kotlintest wrote their own connector") 14 | abstract class SpringFeatureSpec : FeatureSpec(), SpringSpec { 15 | 16 | override val oneInstancePerTest: Boolean = false 17 | 18 | final override fun interceptSpec(context: Spec, spec: () -> Unit) { 19 | autowireAndBeforeAll() 20 | 21 | spec() 22 | } 23 | 24 | @Test 25 | fun loading() { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringFreeSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.runner.KotlinTestSpringRunner 4 | import io.kotlintest.Spec 5 | import io.kotlintest.specs.FreeSpec 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * @author Mischa Holz 11 | */ 12 | @RunWith(KotlinTestSpringRunner::class) 13 | @Deprecated("The core team of kotlintest wrote their own connector") 14 | abstract class SpringFreeSpec : FreeSpec(), SpringSpec { 15 | 16 | override val oneInstancePerTest: Boolean = false 17 | 18 | final override fun interceptSpec(context: Spec, spec: () -> Unit) { 19 | autowireAndBeforeAll() 20 | 21 | spec() 22 | } 23 | 24 | @Test 25 | fun loading() { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringFunSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.runner.KotlinTestSpringRunner 4 | import io.kotlintest.Spec 5 | import io.kotlintest.specs.FunSpec 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * @author Mischa Holz 11 | */ 12 | @RunWith(KotlinTestSpringRunner::class) 13 | @Deprecated("The core team of kotlintest wrote their own connector") 14 | abstract class SpringFunSpec : FunSpec(), SpringSpec { 15 | 16 | override val oneInstancePerTest: Boolean = false 17 | 18 | final override fun interceptSpec(context: Spec, spec: () -> Unit) { 19 | autowireAndBeforeAll() 20 | 21 | spec() 22 | } 23 | 24 | @Test 25 | fun loading() { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringShouldSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.runner.KotlinTestSpringRunner 4 | import io.kotlintest.Spec 5 | import io.kotlintest.specs.ShouldSpec 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * @author Mischa Holz 11 | */ 12 | @RunWith(KotlinTestSpringRunner::class) 13 | @Deprecated("The core team of kotlintest wrote their own connector") 14 | abstract class SpringShouldSpec : ShouldSpec(), SpringSpec { 15 | 16 | override val oneInstancePerTest: Boolean = false 17 | 18 | final override fun interceptSpec(context: Spec, spec: () -> Unit) { 19 | autowireAndBeforeAll() 20 | 21 | spec() 22 | } 23 | 24 | @Test 25 | fun loading() { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.util.AutowireCapableBeanFactoryHolder 4 | 5 | /** 6 | * @author Mischa Holz 7 | */ 8 | 9 | interface SpringSpec { 10 | fun _beforeAll() {} 11 | } 12 | 13 | internal fun SpringSpec.autowireAndBeforeAll() { 14 | AutowireCapableBeanFactoryHolder.factory.autowireBean(this) 15 | 16 | this._beforeAll() 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringStringSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.runner.KotlinTestSpringRunner 4 | import io.kotlintest.Spec 5 | import io.kotlintest.specs.StringSpec 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * @author Mischa Holz 11 | */ 12 | @RunWith(KotlinTestSpringRunner::class) 13 | @Deprecated("The core team of kotlintest wrote their own connector") 14 | abstract class SpringStringSpec : StringSpec(), SpringSpec { 15 | 16 | override val oneInstancePerTest: Boolean = false 17 | 18 | final override fun interceptSpec(context: Spec, spec: () -> Unit) { 19 | autowireAndBeforeAll() 20 | 21 | spec() 22 | } 23 | 24 | @Test 25 | fun loading() { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/SpringWordSpec.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring 2 | 3 | import com.acomodeo.kotlintest.spring.runner.KotlinTestSpringRunner 4 | import io.kotlintest.Spec 5 | import io.kotlintest.specs.WordSpec 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * @author Mischa Holz 11 | */ 12 | @RunWith(KotlinTestSpringRunner::class) 13 | @Deprecated("The core team of kotlintest wrote their own connector") 14 | abstract class SpringWordSpec : WordSpec(), SpringSpec { 15 | 16 | override val oneInstancePerTest: Boolean = false 17 | 18 | final override fun interceptSpec(context: Spec, spec: () -> Unit) { 19 | autowireAndBeforeAll() 20 | 21 | spec() 22 | } 23 | 24 | @Test 25 | fun loading() { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/annotation/EnableKotlinTest.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring.annotation 2 | 3 | import org.springframework.context.annotation.Import 4 | 5 | /** 6 | * @author Mischa Holz 7 | */ 8 | @Import(KotlinTestConfiguration::class) 9 | @Deprecated("The core team of kotlintest wrote their own connector") 10 | annotation class EnableKotlinTest 11 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/annotation/KotlinTestConfiguration.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring.annotation 2 | 3 | import com.acomodeo.kotlintest.spring.util.AutowireCapableBeanFactoryHolder 4 | import org.springframework.context.annotation.Bean 5 | import org.springframework.context.annotation.Configuration 6 | 7 | /** 8 | * @author Mischa Holz 9 | */ 10 | @Configuration 11 | open class KotlinTestConfiguration { 12 | 13 | @Bean 14 | open fun autowireCapableBeanFactoryHolder() = AutowireCapableBeanFactoryHolder() 15 | } 16 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/runner/KotlinTestSpringRunner.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring.runner 2 | 3 | import io.kotlintest.KTestJUnitRunner 4 | import io.kotlintest.Spec 5 | import org.junit.runner.notification.RunNotifier 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner 7 | 8 | /** 9 | * @author Mischa Holz 10 | */ 11 | @Deprecated("The core team of kotlintest wrote their own connector") 12 | class KotlinTestSpringRunner(val testClazz: Class) : SpringJUnit4ClassRunner(testClazz) { 13 | private val kTestRunner = KTestJUnitRunner(testClazz) 14 | 15 | override fun getDescription() = kTestRunner.description 16 | 17 | override fun run(notifier: RunNotifier?) { 18 | super.run(notifier) 19 | 20 | kTestRunner.run(notifier) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/kotlin/com/acomodeo/kotlintest/spring/util/AutowireCapableBeanFactoryHolder.kt: -------------------------------------------------------------------------------- 1 | package com.acomodeo.kotlintest.spring.util 2 | 3 | import org.springframework.beans.factory.annotation.Autowired 4 | import org.springframework.beans.factory.config.AutowireCapableBeanFactory 5 | 6 | /** 7 | * @author Mischa Holz 8 | */ 9 | open class AutowireCapableBeanFactoryHolder { 10 | 11 | companion object { 12 | @JvmStatic 13 | lateinit var factory: AutowireCapableBeanFactory 14 | } 15 | 16 | @Autowired 17 | fun autowireFactory(factory: AutowireCapableBeanFactory) { 18 | Companion.factory = factory 19 | } 20 | } 21 | --------------------------------------------------------------------------------