Skip to content
Permalink
Browse files

Disabled junit4, removed junit5 specific fun and behavior spec, added…

… common versions
  • Loading branch information...
sksamuel committed Sep 4, 2019
1 parent 9cdc3bb commit 026a82ae15bfef36b065b7384d642e017d0291cf
@@ -13,7 +13,7 @@ import io.kotlintest.specs.FunSpec

class AssertionCounterTest : FunSpec() {

override val assertionMode = AssertionMode.Error
override fun assertionMode() = AssertionMode.Error

override fun extensions(): List<TestCaseExtension> = listOf(
object : TestCaseExtension {
@@ -1,15 +1,18 @@
package io.kotlintest.core.specs
package io.kotlintest.specs

import io.kotlintest.Tag
import io.kotlintest.TestType
import io.kotlintest.core.TestCaseConfig
import io.kotlintest.core.TestContext
import io.kotlintest.core.specs.AbstractSpecDsl
import io.kotlintest.core.specs.KotlinTestDsl
import io.kotlintest.core.specs.createTestName
import io.kotlintest.extensions.TestCaseExtension
import kotlin.time.Duration
import kotlin.time.ExperimentalTime

@Suppress("FunctionName")
abstract class AbstractBehaviorSpec(body: AbstractBehaviorSpec.() -> Unit = {}) : AbstractSpecDsl() {
abstract class BehaviorSpec(body: BehaviorSpec.() -> Unit = {}) : AbstractSpecDsl() {

init {
body()
@@ -127,18 +130,18 @@ abstract class AbstractBehaviorSpec(body: AbstractBehaviorSpec.() -> Unit = {})
extensions: List<TestCaseExtension>? = null,
test: TestContext.() -> Unit) {
val config = TestCaseConfig(
enabled ?: this@AbstractBehaviorSpec.defaultTestCaseConfig.enabled,
invocations ?: this@AbstractBehaviorSpec.defaultTestCaseConfig.invocations,
timeout ?: this@AbstractBehaviorSpec.defaultTestCaseConfig.timeout,
threads ?: this@AbstractBehaviorSpec.defaultTestCaseConfig.threads,
tags ?: this@AbstractBehaviorSpec.defaultTestCaseConfig.tags,
extensions ?: this@AbstractBehaviorSpec.defaultTestCaseConfig.extensions)

context.registerTestCase(name, this@AbstractBehaviorSpec, { test.invoke(this) }, config, TestType.Test)
enabled ?: this@BehaviorSpec.defaultTestCaseConfig.enabled,
invocations ?: this@BehaviorSpec.defaultTestCaseConfig.invocations,
timeout ?: this@BehaviorSpec.defaultTestCaseConfig.timeout,
threads ?: this@BehaviorSpec.defaultTestCaseConfig.threads,
tags ?: this@BehaviorSpec.defaultTestCaseConfig.tags,
extensions ?: this@BehaviorSpec.defaultTestCaseConfig.extensions)

context.registerTestCase(name, this@BehaviorSpec, { test.invoke(this) }, config, TestType.Test)
}
}

private val thisSpec: AbstractBehaviorSpec
get() = this@AbstractBehaviorSpec
private val thisSpec: BehaviorSpec
get() = this@BehaviorSpec

}
@@ -1,14 +1,16 @@
package io.kotlintest.core.specs
package io.kotlintest.specs

import io.kotlintest.Tag
import io.kotlintest.TestType
import io.kotlintest.core.TestCaseConfig
import io.kotlintest.core.TestContext
import io.kotlintest.core.specs.AbstractSpecDsl
import io.kotlintest.core.specs.KotlinTestDsl
import io.kotlintest.extensions.TestCaseExtension
import kotlin.time.Duration
import kotlin.time.ExperimentalTime

abstract class AbstractFunSpec(body: AbstractFunSpec.() -> Unit = {}) : AbstractSpecDsl() {
abstract class FunSpec(body: FunSpec.() -> Unit = {}) : AbstractSpecDsl() {

init {
body()
@@ -45,7 +47,7 @@ abstract class AbstractFunSpec(body: AbstractFunSpec.() -> Unit = {}) : Abstract
suspend fun context(name: String, init: suspend ContextScope.() -> Unit) {
context.registerTestCase(
name,
this@AbstractFunSpec,
this@FunSpec,
{ ContextScope(this).init() },
defaultTestCaseConfig,
TestType.Container
@@ -69,14 +71,14 @@ abstract class AbstractFunSpec(body: AbstractFunSpec.() -> Unit = {}) : Abstract
parallelism ?: defaultTestCaseConfig.threads,
tags ?: defaultTestCaseConfig.tags,
extensions ?: defaultTestCaseConfig.extensions)
context.registerTestCase(name, this@AbstractFunSpec, test, config, TestType.Test)
context.registerTestCase(name, this@FunSpec, test, config, TestType.Test)
}
}

fun test(name: String) = TestBuilder(name)

suspend fun test(name: String, test: suspend TestContext.() -> Unit) =
context.registerTestCase(name, this@AbstractFunSpec, test, defaultTestCaseConfig, TestType.Test)
context.registerTestCase(name, this@FunSpec, test, defaultTestCaseConfig, TestType.Test)
}

fun test(name: String) = TestBuilder(name)
@@ -1,3 +1,3 @@
package io.kotlintest

actual fun Spec.resolvedAssertionMode(): AssertionMode = this.assertionMode ?: AssertionMode.None
actual fun Spec.resolvedAssertionMode(): AssertionMode = this.assertionMode() ?: AssertionMode.None

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,12 +1,12 @@
package io.kotlintest.specs

import io.kotlintest.Matcher
import io.kotlintest.core.specs.AbstractBehaviorSpec
import io.kotlintest.core.specs.BehaviorSpec
import io.kotlintest.core.specs.AbstractDescribeSpec
import io.kotlintest.core.specs.AbstractExpectSpec
import io.kotlintest.core.specs.AbstractFeatureSpec
import io.kotlintest.core.specs.AbstractFreeSpec
import io.kotlintest.core.specs.AbstractFunSpec
import io.kotlintest.core.specs.FunSpec
import io.kotlintest.core.specs.AbstractShouldSpec
import io.kotlintest.core.specs.AbstractStringSpec
import io.kotlintest.core.specs.AbstractWordSpec
@@ -18,7 +18,7 @@ import io.kotlintest.should as shouldMatch
abstract class AnnotationSpec(body: AbstractAnnotationSpec.() -> Unit = {}) : AbstractAnnotationSpec(body)

@RunWith(KotlinTestRunner::class)
abstract class BehaviorSpec(body: AbstractBehaviorSpec.() -> Unit = {}) : AbstractBehaviorSpec(body)
abstract class BehaviorSpec(body: BehaviorSpec.() -> Unit = {}) : BehaviorSpec(body)

@RunWith(KotlinTestRunner::class)
abstract class DescribeSpec(body: AbstractDescribeSpec.() -> Unit = {}) : AbstractDescribeSpec(body)
@@ -33,7 +33,7 @@ abstract class FeatureSpec(body: AbstractFeatureSpec.() -> Unit = {}) : Abstract
abstract class FreeSpec(body: AbstractFreeSpec.() -> Unit = {}) : AbstractFreeSpec(body)

@RunWith(KotlinTestRunner::class)
abstract class FunSpec(body: AbstractFunSpec.() -> Unit = {}) : AbstractFunSpec(body) {
abstract class FunSpec(body: FunSpec.() -> Unit = {}) : FunSpec(body) {
@org.junit.Test
@org.junit.Ignore
fun primer() {}
@@ -1,12 +1,10 @@
package io.kotlintest.specs

import io.kotlintest.Matcher
import io.kotlintest.core.specs.AbstractBehaviorSpec
import io.kotlintest.core.specs.AbstractDescribeSpec
import io.kotlintest.core.specs.AbstractExpectSpec
import io.kotlintest.core.specs.AbstractFeatureSpec
import io.kotlintest.core.specs.AbstractFreeSpec
import io.kotlintest.core.specs.AbstractFunSpec
import io.kotlintest.core.specs.AbstractShouldSpec
import io.kotlintest.core.specs.AbstractStringSpec
import io.kotlintest.core.specs.AbstractWordSpec
@@ -22,15 +20,14 @@ interface IntelliMarker {
}

abstract class AnnotationSpec(body: AbstractAnnotationSpec.() -> Unit = {}) : AbstractAnnotationSpec(body), IntelliMarker
abstract class BehaviorSpec(body: AbstractBehaviorSpec.() -> Unit = {}) : AbstractBehaviorSpec(body), IntelliMarker

abstract class DescribeSpec(body: AbstractDescribeSpec.() -> Unit = {}) : AbstractDescribeSpec(body), IntelliMarker
abstract class ExpectSpec(body: AbstractExpectSpec.() -> Unit = {}) : AbstractExpectSpec(body), IntelliMarker

abstract class FeatureSpec(body: AbstractFeatureSpec.() -> Unit = {}) : AbstractFeatureSpec(body), IntelliMarker

abstract class FreeSpec(body: AbstractFreeSpec.() -> Unit = {}) : AbstractFreeSpec(body), IntelliMarker

abstract class FunSpec(body: AbstractFunSpec.() -> Unit = {}) : AbstractFunSpec(body), IntelliMarker

abstract class ShouldSpec(body: AbstractShouldSpec.() -> Unit = {}) : AbstractShouldSpec(body), IntelliMarker {
// need to overload this so that when doing "string" should haveLength(5) in a word spec, we don't
@@ -1,8 +1,8 @@
package com.sksamuel.kotlintest.specs.behavior

import io.kotlintest.core.specs.AbstractBehaviorSpec
import io.kotlintest.specs.BehaviorSpec

class BehaviorSpecExample : AbstractBehaviorSpec() {
class BehaviorSpecExample : BehaviorSpec() {

init {
given("a sheet of string cells 4x4") {
@@ -8,7 +8,6 @@ include 'kotlintest-core',
'kotlintest-runner:kotlintest-runner-jvm',
'kotlintest-runner:kotlintest-runner-console',
'kotlintest-runner:kotlintest-runner-js',
'kotlintest-runner:kotlintest-runner-junit4',
'kotlintest-runner:kotlintest-runner-junit5',
'kotlintest-extensions:kotlintest-extensions-spring',
'kotlintest-extensions:kotlintest-extensions-koin',

0 comments on commit 026a82a

Please sign in to comment.
You can’t perform that action at this time.