mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
start the transition to spek2 - use it for tests based on Expect
For this to work:
- introduce a MPP spec module which uses spek2 and fakes it for JS
- move AnyAssertionsSpec and the new SubjectLessAssertionSpec
into en_GB-common
- update kotlin to 1.3.31 (required by spek2)
- make sure we are still compatible with kotlin 1.2
- put dependency to unzip in bc-test before creating the bc task ->
seems like kotlin 1.3.31 behaves differently here (I guess
dependencies are no longer lazy evaluated or something like that)
- use spek v2.1.0-alpha.0.1+cb69d79 as the stable version has a bug
and AnyAssertionsSpec would not run
This commit is contained in:
@@ -4,11 +4,21 @@ description = 'An assertion function API in en_GB with a focus on code completio
|
||||
'start creating an assertion + code completion + . + code completion + . + and so on.'
|
||||
|
||||
dependencies {
|
||||
compile prefixedProject('domain-builders-jvm')
|
||||
compile prefixedProject('domain-builders-android')
|
||||
|
||||
testRuntimeOnly prefixedProject('domain-robstoll-jvm')
|
||||
testRuntimeOnly prefixedProject('core-robstoll-jvm')
|
||||
testCompile prefixedProject('verbs-internal-jvm')
|
||||
testRuntimeOnly prefixedProject('domain-robstoll-android')
|
||||
testRuntimeOnly prefixedProject('core-robstoll-android')
|
||||
testCompile prefixedProject('verbs-internal-android')
|
||||
}
|
||||
|
||||
//TODO remove once all specs are migrated to spek2
|
||||
junitPlatform {
|
||||
filters {
|
||||
engines {
|
||||
include 'spek2'
|
||||
include 'spek'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
srcAndResourcesFromJvmProject(project)
|
||||
|
||||
@@ -2,4 +2,8 @@ description = 'An assertion function API in en_GB with a focus on code completio
|
||||
|
||||
dependencies {
|
||||
compile prefixedProject('domain-builders-common')
|
||||
|
||||
testRuntimeOnly prefixedProject('domain-robstoll-common')
|
||||
testRuntimeOnly prefixedProject('core-robstoll-common')
|
||||
testImplementation prefixedProject('verbs-internal-common')
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ package ch.tutteli.atrium.api.cc.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.verbs.internal.AssertionVerbFactory
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
|
||||
//import kotlin.reflect.KFunction2
|
||||
//import kotlin.reflect.KProperty1
|
||||
|
||||
class AnyAssertionsSpec : ch.tutteli.atrium.spec.integration.AnyAssertionsSpec(
|
||||
class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec(
|
||||
AssertionVerbFactory,
|
||||
AnyAssertionsSpecFunFactory(),
|
||||
AnyAssertionsSpecFunFactory(),
|
||||
@@ -18,8 +19,9 @@ class AnyAssertionsSpec : ch.tutteli.atrium.spec.integration.AnyAssertionsSpec(
|
||||
// "${toBeNullableCreatorFun.name} with creator" to toBeNullableCreatorFun,
|
||||
// getAndImmediatePair(),
|
||||
// getAndLazyPair()
|
||||
|
||||
) {
|
||||
class AnyAssertionsSpecFunFactory<T : Any> : ch.tutteli.atrium.spec.integration.AnyAssertionsSpec.AnyAssertionsSpecFunFactory<T> {
|
||||
class AnyAssertionsSpecFunFactory<T: Any> : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec.AnyAssertionsSpecFunFactory<T> {
|
||||
override val toBeFun = Expect<T>::toBe
|
||||
// override val notToBeFun = Assert<T>::notToBe
|
||||
// override val isSameFun = Assert<T>::isSameAs
|
||||
@@ -5,4 +5,6 @@ description = 'An assertion function API in en_GB with a focus on code completio
|
||||
|
||||
dependencies {
|
||||
compile prefixedProject('domain-builders-js')
|
||||
|
||||
testCompile prefixedProject('verbs-internal-js')
|
||||
}
|
||||
|
||||
@@ -26,3 +26,13 @@ compileTestKotlin.dependsOn(
|
||||
prefixedProject('domain-robstoll-jvm').compileKotlin,
|
||||
prefixedProject('domain-robstoll-jvm').processResources
|
||||
)
|
||||
|
||||
//TODO remove once all specs are migrated to spek2
|
||||
junitPlatform {
|
||||
filters {
|
||||
engines {
|
||||
include 'spek2'
|
||||
include 'spek'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
build.gradle
48
build.gradle
@@ -8,7 +8,7 @@ buildscript {
|
||||
// main
|
||||
kbox_version = '0.13.0'
|
||||
kbox = { "ch.tutteli.kbox:kbox:$kbox_version" }
|
||||
kotlin_version = '1.2.71'
|
||||
kotlin_version = '1.3.31'
|
||||
mockito_kotlin_version = '2.1.0'
|
||||
mockito = { "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version" }
|
||||
|
||||
@@ -17,6 +17,7 @@ buildscript {
|
||||
junit_platform_version = '1.2.0'
|
||||
jupiter_version = '5.3.1'
|
||||
spek_version = '1.1.5'
|
||||
spek2_version = '2.1.0-alpha.0.1+cb69d79'
|
||||
|
||||
//gh-pages.gradle
|
||||
docProjects = subprojects.findAll { !it.name.contains("robstoll") && it.name != "${rootProject.name}-spec" }
|
||||
@@ -79,11 +80,11 @@ buildscript {
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath "ch.tutteli:tutteli-gradle-project-utils:$gradle.ext.tutteli_plugins_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "ch.tutteli:tutteli-gradle-dokka:$gradle.ext.tutteli_plugins_version"
|
||||
classpath "ch.tutteli:tutteli-gradle-kotlin-module-info:$gradle.ext.tutteli_plugins_version"
|
||||
classpath "ch.tutteli:tutteli-gradle-kotlin-utils:$gradle.ext.tutteli_plugins_version"
|
||||
classpath "ch.tutteli:tutteli-gradle-project-utils:$gradle.ext.tutteli_plugins_version"
|
||||
classpath "ch.tutteli:tutteli-gradle-publish:$gradle.ext.tutteli_plugins_version"
|
||||
classpath "ch.tutteli:tutteli-gradle-spek:$gradle.ext.tutteli_plugins_version"
|
||||
classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0'
|
||||
@@ -101,7 +102,24 @@ repositories {
|
||||
subprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "https://dl.bintray.com/robstoll/tutteli-jars" }
|
||||
maven {
|
||||
url 'https://dl.bintray.com/spekframework/spek'
|
||||
content {
|
||||
includeGroupByRegex 'org\\.spekframework(\\..*)?'
|
||||
}
|
||||
}
|
||||
maven {
|
||||
url "https://dl.bintray.com/spekframework/spek-dev"
|
||||
content {
|
||||
includeGroupByRegex 'org\\.spekframework(\\..*)?'
|
||||
}
|
||||
}
|
||||
maven {
|
||||
url "https://dl.bintray.com/robstoll/tutteli-jars"
|
||||
content {
|
||||
includeGroupByRegex 'ch\\.tutteli(\\..*)?'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,20 +143,24 @@ configure(subprojects - multiplatformProjects - jsExamples) {
|
||||
|
||||
configure(commonProjects) {
|
||||
//TODO activate as soon as https://youtrack.jetbrains.com/issue/KT-30580 is fixed
|
||||
compileTestKotlinCommon{
|
||||
compileKotlinCommon {
|
||||
kotlinOptions.languageVersion = '1.2'
|
||||
}
|
||||
compileTestKotlinCommon {
|
||||
kotlinOptions.allWarningsAsErrors = false
|
||||
}
|
||||
}
|
||||
configure(jsProjects) { subProject ->
|
||||
compileKotlin2Js {
|
||||
kotlinOptions{
|
||||
if(subProject.name.startsWith("atrium-translations")) {
|
||||
//necessary as the module name is then also called atrium-translations-js and can be shared by the other translation modules
|
||||
kotlinOptions {
|
||||
if (subProject.name.startsWith("atrium-translations")) {
|
||||
//necessary as the module name is then also called atrium-translations-js and can be shared (the name) by the other translation modules
|
||||
outputFile = "$buildDir/classes/kotlin/main/atrium-translations-js.js"
|
||||
}
|
||||
languageVersion = '1.2'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO activate as soon as https://youtrack.jetbrains.com/issue/KT-21348 is fixed
|
||||
compileTestKotlin2Js{
|
||||
kotlinOptions.allWarningsAsErrors = false
|
||||
@@ -148,6 +170,9 @@ configure(jsProjects) { subProject ->
|
||||
configure(subprojects - commonProjects - jsProjects - jsExamples) {
|
||||
apply plugin: 'ch.tutteli.dokka'
|
||||
apply plugin: 'ch.tutteli.kotlin.module.info'
|
||||
compileKotlin {
|
||||
kotlinOptions.languageVersion = '1.2'
|
||||
}
|
||||
}
|
||||
|
||||
def apiProjects = subprojects.findAll { it.name.startsWith("${rootProject.name}-api") && it.name.endsWith("-jvm") }
|
||||
@@ -171,13 +196,6 @@ configure(jacocoMulti.jacocoProjects + getAndroidProjects()) {
|
||||
apply plugin: 'ch.tutteli.spek'
|
||||
spek.version = '1.1.5'
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.allWarningsAsErrors = true
|
||||
}
|
||||
compileTestKotlin{
|
||||
kotlinOptions.allWarningsAsErrors = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile mockito(), excludeKotlin
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@file:Suppress("EXPERIMENTAL_FEATURE_WARNING")
|
||||
@file:Suppress("EXPERIMENTAL_FEATURE_WARNING", "DEPRECATION")
|
||||
|
||||
package ch.tutteli.atrium.core.robstoll.lib.reporting.translating
|
||||
|
||||
|
||||
@@ -115,9 +115,9 @@ def createBcAndBbcTasks(String apiName, String oldVersion, String forgive) {
|
||||
|
||||
sourceSets {
|
||||
create(srcName) {
|
||||
java.srcDirs = [] // we don't have java sources
|
||||
kotlin.srcDirs = [srcDirectory]
|
||||
resources.srcDirs = [srcDirectory]
|
||||
java.srcDirs = [] // we don't have java sources
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +200,11 @@ def createBcAndBbcTasks(String apiName, String oldVersion, String forgive) {
|
||||
}
|
||||
}
|
||||
|
||||
project."compileSrc_${nameUnderline}Kotlin" {
|
||||
kotlinOptions.suppressWarnings = true
|
||||
dependsOn unzip
|
||||
}
|
||||
|
||||
def bcTask = task("bc-$name", type: JavaExec, group: 'Verification') {
|
||||
description = "Checks if specs from $apiName $oldVersion can be compiled and run against the current version."
|
||||
|
||||
@@ -231,11 +236,6 @@ def createBcAndBbcTasks(String apiName, String oldVersion, String forgive) {
|
||||
bbcTests.dependsOn bbcTask
|
||||
bcTests.dependsOn jacocoBcReport
|
||||
bcTests.dependsOn bcTask
|
||||
project."compileSrc_${nameUnderline}Kotlin" {
|
||||
kotlinOptions.suppressWarnings = true
|
||||
}
|
||||
|
||||
project."compileSrc_${nameUnderline}Kotlin".dependsOn unzip
|
||||
}
|
||||
|
||||
def createFixSrcTask(String apiName, String oldVersion, String file, Closure modifyContent) {
|
||||
@@ -352,4 +352,3 @@ createFixSrcTask('cc-infix-en_GB', '0.7.0', 'CharSequenceAssertionsSpec.kt') { S
|
||||
createFixSrcTask('cc-infix-en_GB', '0.7.0', 'IterableContainsInOrderOnlyValuesAssertionsSpec.kt') { String content ->
|
||||
return content.replaceAll(/NullableValues<Double>/, 'NullableValues<Double?>')
|
||||
}
|
||||
|
||||
|
||||
28
misc/specs/atrium-specs-android/build.gradle
Normal file
28
misc/specs/atrium-specs-android/build.gradle
Normal file
@@ -0,0 +1,28 @@
|
||||
description = 'Provides specifications of Atrium (for the Android platform) which can be reused by ' +
|
||||
'APIs and domain/core-implementations of Atrium, to verify that they fulfill the specification.'
|
||||
|
||||
dependencies {
|
||||
implementation prefixedProject('domain-api-android')
|
||||
implementation prefixedProject('core-api-android')
|
||||
implementation prefixedProject('domain-builders-android')
|
||||
|
||||
// we need cc-en_GB for compilation and for runtime but we do not want that depending modules have cc-en_GB
|
||||
// automatically in their compile classpath. Thus:
|
||||
compileOnly prefixedProject('api-cc-en_GB-android') // for us
|
||||
runtimeOnly prefixedProject('api-cc-en_GB-android') // for depending modules
|
||||
|
||||
implementation prefixedProject('translations-en_GB-android')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "ch.tutteli.kbox:kbox-android:$kbox_version"
|
||||
|
||||
//spek2 requires stdlib-jdk8 and kotlin-reflect
|
||||
runtimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
|
||||
compile "org.spekframework.spek2:spek-dsl-jvm:$spek2_version", excludeKotlin
|
||||
runtimeOnly "org.spekframework.spek2:spek-runner-junit5:$spek2_version", excludeKotlin
|
||||
}
|
||||
|
||||
srcAndResourcesFromJvmProject(project)
|
||||
20
misc/specs/atrium-specs-common/build.gradle
Normal file
20
misc/specs/atrium-specs-common/build.gradle
Normal file
@@ -0,0 +1,20 @@
|
||||
description = 'Provides specifications of Atrium (as common module) which can be reused by ' +
|
||||
'APIs and domain/core-implementations of Atrium, to verify that they fulfill the specification.'
|
||||
|
||||
dependencies {
|
||||
implementation prefixedProject('domain-api-common')
|
||||
implementation prefixedProject('core-api-common')
|
||||
implementation prefixedProject('domain-builders-common')
|
||||
|
||||
// we need cc-en_GB for compilation and for runtime but we do not want that depending modules have cc-en_GB
|
||||
// automatically in their compile classpath. Thus:
|
||||
compileOnly prefixedProject('api-cc-en_GB-common') // for us
|
||||
runtimeOnly prefixedProject('api-cc-en_GB-common') // for depending modules
|
||||
|
||||
implementation prefixedProject('translations-en_GB-common')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.spekframework.spek2:spek-dsl-metadata:$spek2_version"
|
||||
compile "ch.tutteli.kbox:kbox-common:$kbox_version"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package ch.tutteli.atrium.specs
|
||||
|
||||
import ch.tutteli.kbox.joinToString
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.dsl.GroupBody
|
||||
import org.spekframework.spek2.dsl.Root
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
|
||||
fun GroupBody.describeFunTemplate(
|
||||
describePrefix: String,
|
||||
funNames: Array<out String>,
|
||||
funNamePrefix: String = "`",
|
||||
funNameSuffix: String = "`",
|
||||
body: Suite.() -> Unit
|
||||
) = prefixedDescribe(describePrefix, " fun ",
|
||||
giveWrappedNames(funNames, funNamePrefix, funNameSuffix), body)
|
||||
|
||||
fun GroupBody.describePropertyTemplate(
|
||||
describePrefix: String,
|
||||
propertyNames: Array<out String>,
|
||||
propertyNamePrefix: String = "`",
|
||||
propertyNameSuffix: String = "`",
|
||||
body: Suite.() -> Unit
|
||||
) = prefixedDescribe(
|
||||
describePrefix,
|
||||
" property ",
|
||||
giveWrappedNames(propertyNames, propertyNamePrefix, propertyNameSuffix),
|
||||
body
|
||||
)
|
||||
|
||||
private fun giveWrappedNames(names: Array<out String>, prefix: String, postfix: String): String {
|
||||
return names.joinToString(", ", " and ") { it, sb ->
|
||||
sb.append(prefix).append(it).append(postfix)
|
||||
}
|
||||
}
|
||||
|
||||
fun GroupBody.prefixedDescribe(prefix: String, description: String, body: Suite.() -> Unit) =
|
||||
prefixedDescribe(prefix, "", description, body)
|
||||
|
||||
fun GroupBody.prefixedDescribe(prefix: String, suffix: String, description: String, body: Suite.() -> Unit) =
|
||||
describe("${prefix}describe$suffix $description", body = body)
|
||||
|
||||
fun Root.include(spek: Spek) = spek.root(this)
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.tutteli.atrium.spec.integration
|
||||
package ch.tutteli.atrium.specs
|
||||
|
||||
import ch.tutteli.atrium.assertions.AssertionGroup
|
||||
import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType
|
||||
@@ -6,22 +6,23 @@ import ch.tutteli.atrium.core.coreFactory
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.creating.PlantHasNoSubjectException
|
||||
import ch.tutteli.atrium.domain.builders.AssertImpl
|
||||
import ch.tutteli.atrium.spec.AssertionVerb
|
||||
import org.jetbrains.spek.api.Spek
|
||||
import ch.tutteli.atrium.reporting.translating.Untranslatable
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
|
||||
abstract class NewSubjectLessAssertionSpec<T : Any>(
|
||||
abstract class SubjectLessAssertionSpec<T>(
|
||||
groupPrefix: String,
|
||||
vararg assertionCreator: Pair<String, Expect<T>.() -> Unit>
|
||||
) : Spek({
|
||||
|
||||
group("${groupPrefix}assertion function can be used in an ${AssertionGroup::class.simpleName} with an ${ExplanatoryAssertionGroupType::class.simpleName} and reported without failure") {
|
||||
describe("${groupPrefix}assertion function can be used in an ${AssertionGroup::class.simpleName} with an ${ExplanatoryAssertionGroupType::class.simpleName} and reported without failure") {
|
||||
assertionCreator.forEach { (name, createAssertion) ->
|
||||
test("fun `$name`") {
|
||||
it("fun `$name`") {
|
||||
val assertions = coreFactory.newCollectingAssertionContainer<T> { throw PlantHasNoSubjectException() }
|
||||
.addAssertionsCreatedBy(createAssertion)
|
||||
.getAssertions()
|
||||
val plant = coreFactory.newReportingPlant(
|
||||
AssertionVerb.ASSERT, { 1.0 },
|
||||
Untranslatable("custom assertion verb"), { 1.0 },
|
||||
coreFactory.newOnlyFailureReporter(
|
||||
coreFactory.newAssertionFormatterFacade(coreFactory.newAssertionFormatterController()),
|
||||
coreFactory.newNoOpAtriumErrorAdjuster()
|
||||
@@ -40,4 +41,4 @@ abstract class NewSubjectLessAssertionSpec<T : Any>(
|
||||
/**
|
||||
* Helper function to map an arbitrary `Expect<T>.(...) -> Unit` function to a parameter-less one.
|
||||
*/
|
||||
fun <T : Any> liftToExpect(createAssertion: Expect<T>.() -> Unit): Expect<T>.() -> Unit = createAssertion
|
||||
fun <T> expectLambda(createAssertion: Expect<T>.() -> Unit): Expect<T>.() -> Unit = createAssertion
|
||||
@@ -1,26 +1,33 @@
|
||||
package ch.tutteli.atrium.spec.integration
|
||||
package ch.tutteli.atrium.specs.integration
|
||||
|
||||
import ch.tutteli.atrium.api.cc.en_GB.messageContains
|
||||
//import ch.tutteli.atrium.api.cc.en_GB.toBe
|
||||
import ch.tutteli.atrium.api.cc.en_GB.toThrow
|
||||
//import ch.tutteli.atrium.assertions.DescriptiveAssertion
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
//import ch.tutteli.atrium.reporting.RawString
|
||||
import ch.tutteli.atrium.spec.describeFun
|
||||
import ch.tutteli.atrium.spec.prefixedDescribe
|
||||
//import ch.tutteli.atrium.spec.prefixedDescribe
|
||||
//import ch.tutteli.atrium.spec.setUp
|
||||
import ch.tutteli.atrium.spec.verbs.AssertionVerbFactory
|
||||
import ch.tutteli.atrium.translations.DescriptionAnyAssertion.*
|
||||
import ch.tutteli.atrium.api.cc.en_GB.messageContains
|
||||
import ch.tutteli.atrium.api.cc.en_GB.toBe
|
||||
import ch.tutteli.atrium.api.cc.en_GB.toThrow
|
||||
import ch.tutteli.atrium.core.coreFactory
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.AssertImpl
|
||||
import ch.tutteli.atrium.domain.creating.throwable.thrown.ThrowableThrown
|
||||
import ch.tutteli.atrium.reporting.reporter
|
||||
import ch.tutteli.atrium.reporting.translating.Untranslatable
|
||||
import ch.tutteli.atrium.specs.SubjectLessAssertionSpec
|
||||
import ch.tutteli.atrium.specs.describeFunTemplate
|
||||
import ch.tutteli.atrium.specs.expectLambda
|
||||
import ch.tutteli.atrium.specs.include
|
||||
import ch.tutteli.atrium.specs.verbs.AssertionVerbFactory
|
||||
import ch.tutteli.atrium.translations.DescriptionAnyAssertion.TO_BE
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
//import ch.tutteli.atrium.translations.DescriptionComparableAssertion
|
||||
import org.jetbrains.spek.api.Spek
|
||||
import org.jetbrains.spek.api.dsl.SpecBody
|
||||
import org.jetbrains.spek.api.dsl.context
|
||||
//import org.jetbrains.spek.api.dsl.it
|
||||
import org.jetbrains.spek.api.include
|
||||
|
||||
abstract class AnyAssertionsSpec(
|
||||
verbs: AssertionVerbFactory,
|
||||
funInt: AnyAssertionsSpecFunFactory<Int>,
|
||||
// funNullableInt: AnyAssertionsSpecFunFactory<Int?>,
|
||||
funDataClass: AnyAssertionsSpecFunFactory<DataClass>,
|
||||
toBe: String,
|
||||
// notToBe: String,
|
||||
@@ -34,10 +41,14 @@ abstract class AnyAssertionsSpec(
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : Spek({
|
||||
|
||||
//TODO extend SubjectLess with nullable
|
||||
include(object : NewSubjectLessAssertionSpec<Int>(describePrefix,
|
||||
toBe to liftToExpect { funInt.toBeFun(this, 1) }
|
||||
){})
|
||||
include(object : SubjectLessAssertionSpec<Int>(describePrefix,
|
||||
toBe to expectLambda { funInt.toBeFun(this, 1) }
|
||||
) {})
|
||||
|
||||
//TODO add nullable case
|
||||
// include(object : SubjectLessAssertionSpec<Int?>(describePrefix,
|
||||
// toBe to expectLambda { funNullableInt.toBeFun(this, 1) }
|
||||
// ) {})
|
||||
//
|
||||
// include(object : SubjectLessAssertionSpec<Int>(describePrefix,
|
||||
//
|
||||
@@ -55,11 +66,11 @@ abstract class AnyAssertionsSpec(
|
||||
// checkingTriple(isNotSame, { funInt.isNotSameFun(this, 1) }, 0, 1)
|
||||
// ) {})
|
||||
|
||||
fun prefixedDescribe(description: String, body: SpecBody.() -> Unit)
|
||||
= prefixedDescribe(describePrefix, description, body)
|
||||
// fun prefixedDescribe(description: String, body: Suite.() -> Unit)
|
||||
// = prefixedDescribe(describePrefix, description, body)
|
||||
|
||||
fun describeFun(vararg funName: String, body: SpecBody.() -> Unit)
|
||||
= describeFun(describePrefix, funName, body = body)
|
||||
fun describeFun(vararg funName: String, body: Suite.() -> Unit) =
|
||||
describeFunTemplate(describePrefix, funName, body = body)
|
||||
|
||||
val expect = verbs::checkException
|
||||
val assert: (Int) -> Expect<Int> = verbs::checkImmediately
|
||||
@@ -70,7 +81,8 @@ abstract class AnyAssertionsSpec(
|
||||
// val (and, andProperty) = andPair
|
||||
// val (andLazy, andLazyGroup) = andLazyPair
|
||||
|
||||
describeFun(toBe) {//, notToBe, isSame, isNotSame) {
|
||||
describeFun(toBe) {
|
||||
//, notToBe, isSame, isNotSame) {
|
||||
|
||||
context("primitive") {
|
||||
val toBeFun: Expect<Int>.(Int) -> Expect<Int> = funInt.toBeFun
|
||||
@@ -79,7 +91,7 @@ abstract class AnyAssertionsSpec(
|
||||
// val isNotSameFun: Expect<Int>.(Int) -> Expect<Int> = funInt.isNotSameFun
|
||||
|
||||
context("one equals the other") {
|
||||
test("$toBe does not throw") {
|
||||
it("$toBe does not throw") {
|
||||
assert(1).toBeFun(1)
|
||||
}
|
||||
// test("$isSame does not throw") {
|
||||
@@ -97,7 +109,7 @@ abstract class AnyAssertionsSpec(
|
||||
// }
|
||||
}
|
||||
context("one does not equal the other") {
|
||||
test("$toBe throws AssertionError") {
|
||||
it("$toBe throws AssertionError") {
|
||||
expect {
|
||||
assert(1).toBeFun(2)
|
||||
}.toThrow<AssertionError> { messageContains(TO_BE.getDefault()) }
|
||||
@@ -123,7 +135,7 @@ abstract class AnyAssertionsSpec(
|
||||
// val isSameFun: Expect<DataClass>.(DataClass) -> Expect<DataClass> = funDataClass.isSameFun
|
||||
// val isNotSameFun: Expect<DataClass>.(DataClass) -> Expect<DataClass> = funDataClass.isNotSameFun
|
||||
context("same") {
|
||||
test("$toBe does not throw") {
|
||||
it("$toBe does not throw") {
|
||||
fluent.toBeFun(test)
|
||||
}
|
||||
// test("$notToBe throws AssertionError") {
|
||||
@@ -142,7 +154,7 @@ abstract class AnyAssertionsSpec(
|
||||
}
|
||||
context("not same but one equals the other") {
|
||||
val other = DataClass(true)
|
||||
test("$toBe does not throw") {
|
||||
it("$toBe does not throw") {
|
||||
fluent.toBeFun(other)
|
||||
}
|
||||
// test("$notToBe throws AssertionError") {
|
||||
@@ -161,10 +173,10 @@ abstract class AnyAssertionsSpec(
|
||||
}
|
||||
context("one does not equal the other") {
|
||||
val other = DataClass(false)
|
||||
test("$toBe does not throw") {
|
||||
it("$toBe does not throw") {
|
||||
expect {
|
||||
fluent.toBeFun(other)
|
||||
}.toThrow<AssertionError>{}
|
||||
}.toThrow<AssertionError> {}
|
||||
}
|
||||
// test("$notToBe throws AssertionError") {
|
||||
// fluent.notToBeFun(other)
|
||||
@@ -304,7 +316,7 @@ abstract class AnyAssertionsSpec(
|
||||
// }
|
||||
|
||||
}) {
|
||||
interface AnyAssertionsSpecFunFactory<T : Any> {
|
||||
interface AnyAssertionsSpecFunFactory<T> {
|
||||
val toBeFun: Expect<T>.(T) -> Expect<T>
|
||||
// val notToBeFun: Expect<T>.(T) -> Expect<T>
|
||||
// val isSameFun: Expect<T>.(T) -> Expect<T>
|
||||
@@ -0,0 +1,6 @@
|
||||
package ch.tutteli.atrium.specs.integration
|
||||
|
||||
import org.spekframework.spek2.Spek
|
||||
|
||||
abstract class A(val a: String): Spek({})
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package ch.tutteli.atrium.spec.verbs
|
||||
package ch.tutteli.atrium.specs.verbs
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.creating.throwable.thrown.ThrowableThrown
|
||||
|
||||
interface AssertionVerbFactory {
|
||||
fun <T> checkImmediately(subject: T): Expect<T>
|
||||
fun <T> checkLazily(subject: T, assertionCreator: Expect<T>.() -> Unit): Expect<T>
|
||||
fun checkException(act: () -> Unit): ThrowableThrown.Builder
|
||||
}
|
||||
|
||||
20
misc/specs/atrium-specs-js/build.gradle
Normal file
20
misc/specs/atrium-specs-js/build.gradle
Normal file
@@ -0,0 +1,20 @@
|
||||
description = 'Provides specifications of Atrium (for the JS platforms) which can be reused by ' +
|
||||
'APIs and domain/core-implementations of Atrium, to verify that they fulfill the specification.'
|
||||
|
||||
dependencies {
|
||||
implementation prefixedProject('domain-api-js')
|
||||
implementation prefixedProject('core-api-js')
|
||||
implementation prefixedProject('domain-builders-js')
|
||||
|
||||
// we need cc-en_GB for compilation and for runtime but we do not want that depending modules have cc-en_GB
|
||||
// automatically in their compile classpath. Thus:
|
||||
compileOnly prefixedProject('api-cc-en_GB-js') // for us
|
||||
runtimeOnly prefixedProject('api-cc-en_GB-js') // for depending modules
|
||||
|
||||
implementation prefixedProject('translations-en_GB-js')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "ch.tutteli.kbox:kbox-js:$kbox_version"
|
||||
//TODO use spek2 js artifact as soon as the following is released: https://github.com/spekframework/spek/issues/706
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//TODO remove as soon as https://github.com/spekframework/spek/issues/706 is fixed
|
||||
package org.spekframework.spek2
|
||||
|
||||
import org.spekframework.spek2.dsl.Root
|
||||
|
||||
@Suppress("UnnecessaryAbstractClass")
|
||||
abstract class Spek(val root: Root.() -> Unit)
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.spekframework.spek2.dsl
|
||||
|
||||
interface GroupBody {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.spekframework.spek2.dsl
|
||||
|
||||
import org.spekframework.spek2.lifecycle.CachingMode
|
||||
import org.spekframework.spek2.style.specification.MemoizedValue
|
||||
|
||||
interface Root: GroupBody {
|
||||
fun <T> memoized(mode: CachingMode = CachingMode.EACH_GROUP, body: () -> T): MemoizedValue<T> = throw IllegalStateException("not implemented")
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//TODO remove as soon as https://github.com/spekframework/spek/issues/706 is fixed
|
||||
package org.spekframework.spek2.lifecycle
|
||||
|
||||
enum class CachingMode {
|
||||
/**
|
||||
* Each group will get their own unique instance. Nested groups will have
|
||||
* their own unique instance as well.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use CachingMode.EACH_GROUP instead.",
|
||||
replaceWith = ReplaceWith("org.spekframework.spek2.lifecylce.CachingMode.EACH_GROUP")
|
||||
)
|
||||
GROUP,
|
||||
/**
|
||||
* Each group will get their own unique instance. Nested groups will have
|
||||
* their own unique instance as well.
|
||||
*/
|
||||
EACH_GROUP,
|
||||
|
||||
/**
|
||||
* Instance will be shared within the group it was declared.
|
||||
*/
|
||||
SCOPE,
|
||||
|
||||
/**
|
||||
* Each test will get their own unique instance.
|
||||
*/
|
||||
TEST,
|
||||
|
||||
INHERIT
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//TODO remove as soon as https://github.com/spekframework/spek/issues/706 is fixed
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
package org.spekframework.spek2.style.specification
|
||||
|
||||
import org.spekframework.spek2.dsl.GroupBody
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
interface MemoizedValue<out T> {
|
||||
operator fun provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty<Any?, T>
|
||||
}
|
||||
|
||||
interface Suite{
|
||||
fun it(description: String, body: Suite.() -> Unit){}
|
||||
fun context(description: String, body: Suite.() -> Unit){}
|
||||
fun beforeEachTest(body: Suite.() -> Unit){}
|
||||
}
|
||||
|
||||
fun GroupBody.describe(description: String, body: Suite.() -> Unit){}
|
||||
28
misc/specs/atrium-specs-jvm/build.gradle
Normal file
28
misc/specs/atrium-specs-jvm/build.gradle
Normal file
@@ -0,0 +1,28 @@
|
||||
description = 'Provides specifications of Atrium (for the JVM platform) which can be reused by ' +
|
||||
'APIs and domain/core-implementations of Atrium, to verify that they fulfill the specification.'
|
||||
|
||||
dependencies {
|
||||
implementation prefixedProject('domain-api-jvm')
|
||||
implementation prefixedProject('core-api-jvm')
|
||||
implementation prefixedProject('domain-builders-jvm')
|
||||
|
||||
// we need cc-en_GB for compilation and for runtime but we do not want that depending modules have cc-en_GB
|
||||
// automatically in their compile classpath. Thus:
|
||||
compileOnly prefixedProject('api-cc-en_GB-jvm') // for us
|
||||
runtimeOnly prefixedProject('api-cc-en_GB-jvm') // for depending modules
|
||||
|
||||
implementation prefixedProject('translations-en_GB-jvm')
|
||||
|
||||
implementation "ch.tutteli.kbox:kbox:$kbox_version", excludeKotlin
|
||||
testRuntimeOnly prefixedProject('domain-robstoll-jvm')
|
||||
testRuntimeOnly prefixedProject('core-robstoll-jvm')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
//spek2 requires stdlib-jdk8 and kotlin-reflect
|
||||
runtimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
|
||||
compile "org.spekframework.spek2:spek-dsl-jvm:$spek2_version", excludeKotlin
|
||||
runtimeOnly "org.spekframework.spek2:spek-runner-junit5:$spek2_version", excludeKotlin
|
||||
}
|
||||
@@ -4,6 +4,7 @@ dependencies {
|
||||
compile prefixedProject('core-api-android')
|
||||
compile prefixedProject('domain-builders-android')
|
||||
compile prefixedProject('spec')
|
||||
compile prefixedProject('specs-android')
|
||||
|
||||
testCompile prefixedProject('domain-robstoll-android')
|
||||
testCompile prefixedProject('core-robstoll-android')
|
||||
|
||||
@@ -3,6 +3,7 @@ description = 'Specifies the internally used assertion verbs as common module'
|
||||
dependencies {
|
||||
compile prefixedProject('core-api-common')
|
||||
compile prefixedProject('domain-builders-common')
|
||||
compile prefixedProject('specs-common')
|
||||
|
||||
testCompile prefixedProject('domain-robstoll-common')
|
||||
testCompile prefixedProject('core-robstoll-common')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ch.tutteli.atrium.api.verbs.internal
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.reporting.ObjectFormatter
|
||||
import ch.tutteli.atrium.reporting.Reporter
|
||||
|
||||
@@ -9,8 +8,7 @@ import ch.tutteli.atrium.reporting.Reporter
|
||||
* or an own assertion function API (e.g., atrium-api-cc-en_GB in a different language)
|
||||
* and you want to reuse a specification from atrium-spec to test your custom component against it.
|
||||
*/
|
||||
object AssertionVerbFactory : ch.tutteli.atrium.spec.verbs.AssertionVerbFactory {
|
||||
object AssertionVerbFactory : ch.tutteli.atrium.specs.verbs.AssertionVerbFactory {
|
||||
override fun <T> checkImmediately(subject: T) = assert(subject)
|
||||
override fun <T> checkLazily(subject: T, assertionCreator: Expect<T>.() -> Unit) = assert(subject, assertionCreator)
|
||||
override fun checkException(act: () -> Unit) = expect(act)
|
||||
}
|
||||
@@ -4,6 +4,7 @@ dependencies {
|
||||
compile prefixedProject('core-api-js')
|
||||
compile prefixedProject('domain-builders-js')
|
||||
compile prefixedProject('translations-en_GB-js')
|
||||
compile prefixedProject('specs-js')
|
||||
|
||||
testCompile prefixedProject('domain-robstoll-js')
|
||||
testCompile prefixedProject('core-robstoll-js')
|
||||
|
||||
@@ -4,6 +4,7 @@ dependencies {
|
||||
compile prefixedProject('core-api-jvm')
|
||||
compile prefixedProject('domain-builders-jvm')
|
||||
compile prefixedProject('spec')
|
||||
compile prefixedProject('specs-jvm')
|
||||
|
||||
testCompile prefixedProject('domain-robstoll-jvm')
|
||||
testCompile prefixedProject('core-robstoll-jvm')
|
||||
|
||||
@@ -70,6 +70,7 @@ include {
|
||||
misc {
|
||||
_ 'bc-test'
|
||||
_ 'spec'
|
||||
kotlinJvmJsAndAndroidIfCi(delegate, 'specs')
|
||||
folder('examples/js') {
|
||||
project('mocha')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user