xmlking
10/09/2016, 4:15 AMxmlking
10/09/2016, 4:15 AMapply plugin: 'nebula.kotlin'
junitPlatform {
engines {
include 'spek'
}
}
dependencies {
// compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:$mybatisBootVersion"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.cloud:spring-cloud-starter-bus-kafka"
// compile "org.springframework.cloud:spring-cloud-starter-config"
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
// compile "org.springframework.boot:spring-boot-devtools"
// runtime "mysql:mysql-connector-java"
runtime "com.h2database:h2"
testCompile "com.nhaarman:mockito-kotlin:$mockitoKotlinVersion"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion" //Assertion Framework
testCompile "org.jetbrains.spek:spek-api:$spekVersion"
testRuntime "org.jetbrains.spek:spek-junit-platform-engine:$spekVersion"
}
bootRepackage {
it.mustRunAfter clean
}
xmlking
10/09/2016, 4:16 AMxmlking
10/09/2016, 4:16 AMbuildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M2'
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE'
}
}
plugins {
id "com.github.johnrengelman.shadow" version "1.2.3" apply false
// id "spring-boot" version "1.4.2.RELEASE" apply false
id "nebula.kotlin" version "1.1.0-M01-5" apply false
}
group "com.sumo.cloudnative"
subprojects {
apply plugin: 'application'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'spring-boot'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile "ch.qos.logback:logback-classic:$logbackVersion"
}
jar {
manifest {
attributes(
"Implementation-Version": version,
'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
}
}
}
wrapper {
gradleVersion = gradleWrapperVersion
}
xmlking
10/09/2016, 4:18 AMxmlking
10/09/2016, 4:18 AMhhariri
roman.belov
10/09/2016, 6:02 AMcraigjbass
10/09/2016, 10:58 AMlangara
10/16/2016, 9:10 AMfun <T> Dsl.rule(before: () -> T, after: (T) -> Unit = {}) = object : ReadOnlyProperty<Any?, T> {
private var currentValue: T = before()
init {
beforeEach { currentValue = before() }
afterEach { after(currentValue) }
}
override fun getValue(thisRef: Any?, property: KProperty<*>) = currentValue
}
And then use it like this:
given("something") {
val something by rule { createSomething() }
...
}
But kotlin compiler (1.0.x) does not allow to delegate local properties 😞hannesstruss
10/16/2016, 10:40 AMSubjectSpek
, but when using a custom class my tests aren’t picked up. Looks like that is currently hardcoded: https://github.com/JetBrains/spek/blob/master/spek-junit-platform-engine/src/main/kotlin/org/jetbrains/spek/engine/SpekTestEngine.kt#L46-L48hannesstruss
10/16/2016, 10:41 AMDsl
the way to go (like Marek proposes above, what a coincidence :))?raniejade
10/16/2016, 11:15 AMhannesstruss
10/16/2016, 11:18 AMstore
, FixtureStore
and FixtureDelegate
in a utility superclasshannesstruss
10/16/2016, 11:18 AMhannesstruss
10/16/2016, 11:19 AMDsl
would provide no way to store the store
raniejade
10/16/2016, 11:20 AMraniejade
10/16/2016, 11:20 AMraniejade
10/16/2016, 11:21 AMhannesstruss
10/16/2016, 11:23 AMraniejade
10/16/2016, 11:31 AM1.1
🙂orangy
fun String.invoke(body: Dsl.() -> Unit) = describe(this, body)
and use it like
“given an instance” {
…
“on calling method” {
…
}
}
I thought it could be indeed nice way for describing speks 🙂raniejade
10/16/2016, 12:54 PMhannesstruss
10/16/2016, 1:11 PMextensionRegistry
in this example?
inline fun <reified T> Dsl.mock(): ObjectDelegate<T> {
return extensionRegistry.getExtension(MockitoExtension::class)
.mock()
}
raniejade
10/16/2016, 1:14 PMextension-playground
branch, basically Dsl
now exposes an ExtensionRegistry
.hannesstruss
10/16/2016, 1:15 PMraniejade
10/16/2016, 1:17 PMvint
10/16/2016, 1:42 PMval context = InstrumentationRegistry.getTargetContext()
val realmConfiguration = RealmConfiguration.Builder(context)
.name("TestRealm")
.inMemory()
.build()
realm = Realm.getInstance(realmConfiguration)
but now I’m using Spek
I'm wondering how can I achieve that because my tests are now in JUnit test and I cannot get the context to build Realm configuration.bj0
10/21/2016, 11:27 PM