Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
19 changed files
with
824 additions
and
17 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...i/src/commonMain/kotlin/io/kotest/core/spec/style/scopes/ContainerContextConfigBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.kotest.core.spec.style.scopes | ||
|
||
import io.kotest.common.ExperimentalKotest | ||
import io.kotest.core.Tag | ||
import io.kotest.core.test.DescriptionName | ||
import io.kotest.core.test.EnabledIf | ||
import io.kotest.core.test.EnabledOrReasonIf | ||
import io.kotest.core.test.TestContext | ||
import io.kotest.core.test.TestType | ||
import io.kotest.core.test.createNestedTest | ||
import io.kotest.core.test.deriveTestContainerConfig | ||
import io.kotest.core.test.toTestCaseConfig | ||
import io.kotest.core.test.toTestContainerConfig | ||
import kotlin.time.Duration | ||
|
||
@ExperimentalKotest | ||
class ContainerContextConfigBuilder<T>( | ||
private val name: DescriptionName.TestName, | ||
private val context: TestContext, | ||
private val xdisabled: Boolean, | ||
private val contextFn: (TestContext) -> T | ||
) { | ||
|
||
suspend fun config( | ||
enabled: Boolean? = null, | ||
enabledIf: EnabledIf? = null, | ||
enabledOrReasonIf: EnabledOrReasonIf? = null, | ||
tags: Set<Tag>? = null, | ||
timeout: Duration? = null, | ||
test: suspend T.() -> Unit | ||
) { | ||
|
||
val derivedConfig = context.testCase.config.toTestContainerConfig().deriveTestContainerConfig( | ||
enabled = enabled, | ||
enabledIf = enabledIf, | ||
enabledOrReasonIf = enabledOrReasonIf, | ||
tags = tags, | ||
timeout = timeout, | ||
) | ||
|
||
val activeConfig = if (xdisabled) derivedConfig.copy(enabled = false) else derivedConfig | ||
|
||
context.registerTestCase( | ||
createNestedTest( | ||
name = name, | ||
xdisabled = xdisabled, | ||
config = activeConfig.toTestCaseConfig(), | ||
type = TestType.Container, | ||
descriptor = null, | ||
factoryId = context.testCase.factoryId, | ||
test = { contextFn(this).test() } | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...rk-api/src/commonMain/kotlin/io/kotest/core/spec/style/scopes/RootContextConfigBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.kotest.core.spec.style.scopes | ||
|
||
import io.kotest.common.ExperimentalKotest | ||
import io.kotest.core.Tag | ||
import io.kotest.core.test.DescriptionName | ||
import io.kotest.core.test.EnabledIf | ||
import io.kotest.core.test.EnabledOrReasonIf | ||
import io.kotest.core.test.TestContext | ||
import io.kotest.core.test.TestType | ||
import io.kotest.core.test.deriveTestContainerConfig | ||
import io.kotest.core.test.toTestCaseConfig | ||
import io.kotest.core.test.toTestContainerConfig | ||
import kotlin.time.Duration | ||
|
||
@ExperimentalKotest | ||
class RootContextConfigBuilder<T>( | ||
private val name: DescriptionName.TestName, | ||
private val registration: RootTestRegistration, | ||
private val xdisabled: Boolean, | ||
val contextFn: (TestContext) -> T | ||
) { | ||
|
||
@ExperimentalKotest | ||
fun config( | ||
enabled: Boolean? = null, | ||
enabledIf: EnabledIf? = null, | ||
enabledOrReasonIf: EnabledOrReasonIf? = null, | ||
tags: Set<Tag>? = null, | ||
timeout: Duration? = null, | ||
test: suspend T.() -> Unit | ||
) { | ||
|
||
val derivedConfig = registration.defaultConfig | ||
.toTestContainerConfig() | ||
.deriveTestContainerConfig( | ||
enabled = enabled, | ||
enabledIf = enabledIf, | ||
enabledOrReasonIf = enabledOrReasonIf, | ||
tags = tags, | ||
timeout = timeout, | ||
) | ||
|
||
registration.addTest( | ||
name, | ||
xdisabled, | ||
derivedConfig.toTestCaseConfig(), | ||
TestType.Container | ||
) { contextFn(this).test() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.