How to use ResolvedTestConfig class of io.kotest.core.test.config package

Best Kotest code snippet using io.kotest.core.test.config.ResolvedTestConfig

IsEnabledTest.kt

Source:IsEnabledTest.kt Github

copy

Full Screen

...16import io.kotest.core.spec.style.StringSpec17import io.kotest.core.test.Enabled18import io.kotest.core.test.TestCase19import io.kotest.core.test.TestType20import io.kotest.core.test.config.ResolvedTestConfig21import io.kotest.engine.test.status.isEnabled22import io.kotest.engine.test.status.isEnabledInternal23import io.kotest.matchers.shouldBe24@ExperimentalKotest25class IsEnabledTest : StringSpec() {26 init {27 "isEnabledInternal should return false if the test is disabled in config" {28 val test = TestCase(29 name = TestName("foo"),30 descriptor = IsEnabledTest::class.toDescriptor().append("foo"),31 spec = this@IsEnabledTest,32 parent = null,33 test = {},34 config = ResolvedTestConfig.default.copy(enabled = { Enabled.disabled }),35 type = TestType.Test,36 )37 test.isEnabledInternal(ProjectConfiguration()).isEnabled shouldBe false38 }39 "isEnabledInternal should return false if it has an excluded tag" {40 val mytag = NamedTag("mytag")41 val ext = object : TagExtension {42 override fun tags(): TagExpression =43 TagExpression(emptySet(), setOf(mytag))44 }45 val c = ProjectConfiguration()46 c.registry.add(ext)47 val test = TestCase(48 name = TestName("foo"),49 descriptor = IsEnabledTest::class.toDescriptor().append("foo"),50 spec = this@IsEnabledTest,51 parent = null,52 test = {},53 config = ResolvedTestConfig.default.copy(tags = setOf(mytag)),54 type = TestType.Test,55 )56 test.isEnabledInternal(c).isEnabled shouldBe false57 }58 "isEnabledInternal should return false if it is excluded by a tag expression" {59 val mytag = NamedTag("mytag")60 val ext = object : TagExtension {61 override fun tags(): TagExpression = TagExpression("!mytag")62 }63 val c = ProjectConfiguration()64 c.registry.add(ext)65 val test = TestCase(66 name = TestName("foo"),67 descriptor = IsEnabledTest::class.toDescriptor().append("foo"),68 spec = this@IsEnabledTest,69 parent = null,70 test = {},71 config = ResolvedTestConfig.default.copy(tags = setOf(mytag)),72 type = TestType.Test,73 )74 test.isEnabledInternal(c).isEnabled shouldBe false75 }76 "isEnabledInternal should return false if it has no tags and included tags are set" {77 val yourtag = NamedTag("yourtag")78 val ext = object : TagExtension {79 override fun tags(): TagExpression = TagExpression(setOf(yourtag), emptySet())80 }81 val c = ProjectConfiguration()82 c.registry.add(ext)83 val mytag = NamedTag("mytag")84 val test = TestCase(85 name = TestName("foo"),86 descriptor = IsEnabledTest::class.toDescriptor().append("foo"),87 spec = this@IsEnabledTest,88 parent = null,89 test = {},90 config = ResolvedTestConfig.default.copy(tags = setOf(mytag)),91 type = TestType.Test,92 )93 test.isEnabledInternal(c).isEnabled shouldBe false94 }95 "isEnabledInternal should return false if it has no tags and a tag expression with include is set" {96 val ext = object : TagExtension {97 override fun tags(): TagExpression = TagExpression("yourtag")98 }99 val c = ProjectConfiguration()100 c.registry.add(ext)101 val mytag = NamedTag("mytag")102 val test = TestCase(103 name = TestName("foo"),104 descriptor = IsEnabledTest::class.toDescriptor().append("foo"),105 spec = this@IsEnabledTest,106 parent = null,107 test = {},108 config = ResolvedTestConfig.default.copy(tags = setOf(mytag)),109 type = TestType.Test,110 )111 test.isEnabledInternal(c).isEnabled shouldBe false112 }113 "isEnabledInternal should return false if the test name begins with a !" {114 val test = TestCase(115 name = TestName("!foo"),116 descriptor = IsEnabledTest::class.toDescriptor().append("!foo"),117 spec = this@IsEnabledTest,118 parent = null,119 test = {},120 config = ResolvedTestConfig.default,121 type = TestType.Test,122 )123 test.isEnabledInternal(ProjectConfiguration()).isEnabled shouldBe false124 }125 "isEnabledInternal should return false if the test is not focused and the spec contains OTHER focused tests" {126 val test = TestCase(127 name = TestName("foo"),128 descriptor = IsEnabledWithFocusTest::class.toDescriptor().append("foo"),129 spec = IsEnabledWithFocusTest(),130 parent = null,131 test = {},132 config = ResolvedTestConfig.default,133 type = TestType.Test,134 )135 test.isEnabledInternal(ProjectConfiguration()).isEnabled shouldBe false136 }137 "isEnabledInternal should return true if the test is focused and top level" {138 val test = TestCase(139 name = TestName("f:foo"),140 descriptor = IsEnabledWithFocusTest::class.toDescriptor().append("f:foo"),141 spec = IsEnabledWithFocusTest(),142 parent = null,143 test = {},144 config = ResolvedTestConfig.default,145 type = TestType.Test,146 )147 test.isEnabledInternal(ProjectConfiguration()).isEnabled shouldBe true148 }149 "isEnabledInternal should return true if not top level even if spec has top level focused tests" {150 val test = TestCase(151 name = TestName("f:my test"),152 descriptor = IsEnabledWithFocusTest::class.toDescriptor().append("f:my test").append("foo"),153 spec = IsEnabledWithFocusTest(),154 parent = null,155 test = {},156 config = ResolvedTestConfig.default,157 type = TestType.Test,158 )159 test.isEnabledInternal(ProjectConfiguration()).isEnabled shouldBe true160 }161 "isEnabledInternal should return false if a test filter excludes the test" {162 val filter = object : TestFilter {163 override fun filter(descriptor: Descriptor): TestFilterResult {164 return (descriptor.id.value == "f").toTestFilterResult(null)165 }166 }167 val c = ProjectConfiguration()168 c.registry.add(filter)169 TestCase(170 name = TestName("f"),171 descriptor = SomeTestClass::class.toDescriptor().append("f"),172 spec = SomeTestClass(),173 parent = null,174 test = {},175 config = ResolvedTestConfig.default,176 type = TestType.Test,177 ).isEnabledInternal(c).isEnabled shouldBe true178 TestCase(179 name = TestName("g"),180 descriptor = SomeTestClass::class.toDescriptor().append("g"),181 spec = SomeTestClass(),182 parent = null,183 test = {},184 config = ResolvedTestConfig.default,185 type = TestType.Test,186 ).isEnabledInternal(c).isEnabled shouldBe false187 }188 "isEnabled should use extensions when registered" {189 val ext = object : EnabledExtension {190 override suspend fun isEnabled(descriptor: Descriptor) =191 if (descriptor.id.value.contains("activateme"))192 Enabled.enabled193 else194 Enabled.disabled("descriptor name does not contain activateme")195 }196 val c = ProjectConfiguration()197 c.registry.add(ext)198 // this should be disabled because the extension says it is, even though it's normally enabled199 TestCase(200 name = TestName("enabled"),201 descriptor = SomeTestClass::class.toDescriptor().append("enabled"),202 spec = SomeTestClass(),203 parent = null,204 test = {},205 config = ResolvedTestConfig.default,206 type = TestType.Test,207 ).isEnabled(c).isEnabled shouldBe false208 TestCase(209 name = TestName("activateme"),210 descriptor = SomeTestClass::class.toDescriptor().append("activateme"),211 spec = SomeTestClass(),212 parent = null,213 test = {},214 config = ResolvedTestConfig.default,215 type = TestType.Test,216 ).isEnabled(c).isEnabled shouldBe true217 }218 }219}220class SomeTestClass : FunSpec({221 test("f") {}222 test("g") {}223})224class IsEnabledWithFocusTest : FunSpec({225 test("f: focused") {}226 test("not focused") {}227})...

Full Screen

Full Screen

DefaultDisplayNameFormatterTest.kt

Source:DefaultDisplayNameFormatterTest.kt Github

copy

Full Screen

...10import io.kotest.core.annotation.Isolate11import io.kotest.core.spec.style.FunSpec12import io.kotest.core.test.TestCase13import io.kotest.core.test.TestType14import io.kotest.core.test.config.ResolvedTestConfig15import io.kotest.engine.test.names.DefaultDisplayNameFormatter16import io.kotest.matchers.shouldBe17@Isolate18class DefaultDisplayNameFormatterTest : FunSpec() {19 init {20 test("@DisplayName should be used for spec name") {21 DefaultDisplayNameFormatter(ProjectConfiguration()).format(SpecWithDisplayName::class) shouldBe "ZZZZZ"22 }23 test("test name should use full path option") {24 val conf = ProjectConfiguration()25 conf.displayFullTestPath = true26 val tc1 = TestCase(27 SpecWithDisplayName::class.toDescriptor().append("test"),28 TestName("test"),29 SpecWithDisplayName(),30 {},31 sourceRef(),32 TestType.Test,33 )34 val tc2 = TestCase(35 SpecWithDisplayName::class.toDescriptor().append("test2"),36 TestName("test2"),37 SpecWithDisplayName(),38 {},39 sourceRef(),40 TestType.Test,41 parent = tc142 )43 DefaultDisplayNameFormatter(conf).format(tc2) shouldBe "test test2"44 }45 test("tags should be appended from config when configuration is set") {46 val c = ProjectConfiguration()47 c.testNameAppendTags = true48 val tc = TestCase(49 SpecWithDisplayName::class.toDescriptor().append("test"),50 TestName("test"),51 SpecWithDisplayName(),52 {},53 sourceRef(),54 TestType.Test,55 ResolvedTestConfig.default.copy(tags = setOf(NamedTag("Foo"), Dummy))56 )57 DefaultDisplayNameFormatter(c).format(tc) shouldBe "test[tags = Foo, Dummy]"58 }59 test("bang should not be included in test name") {60 val tc = TestCase(61 descriptor = SpecWithDisplayName::class.toDescriptor().append("!test"),62 name = TestName("!test"),63 spec = SpecWithDisplayName(),64 test = {},65 source = sourceRef(),66 type = TestType.Test,67 config = ResolvedTestConfig.default.copy(tags = setOf(Dummy, NoUse))68 )69 DefaultDisplayNameFormatter(ProjectConfiguration()).format(tc) shouldBe "test"70 }71 test("focus should not be included in test name") {72 val tc = TestCase(73 descriptor = SpecWithDisplayName::class.toDescriptor().append("f:test"),74 name = TestName("f:test"),75 spec = SpecWithDisplayName(),76 test = {},77 source = sourceRef(),78 type = TestType.Test,79 config = ResolvedTestConfig.default.copy(tags = setOf(Dummy, NoUse))80 )81 DefaultDisplayNameFormatter(ProjectConfiguration()).format(tc) shouldBe "test"82 }83 test("name should include prefix if affixes are included by default") {84 val tc = TestCase(85 descriptor = SpecWithDisplayName::class.toDescriptor().append("f:test"),86 name = TestName("prefix", "foo", null, true),87 spec = SpecWithDisplayName(),88 test = {},89 source = sourceRef(),90 type = TestType.Test,91 config = ResolvedTestConfig.default.copy(tags = setOf(Dummy, NoUse))92 )93 DefaultDisplayNameFormatter(ProjectConfiguration()).format(tc) shouldBe "prefixfoo"94 }95 test("name should include prefix if affixes are excluded by default but enabled by config") {96 val tc = TestCase(97 descriptor = SpecWithDisplayName::class.toDescriptor().append("f:test"),98 name = TestName("prefix", "foo", null, false),99 spec = SpecWithDisplayName(),100 test = {},101 source = sourceRef(),102 type = TestType.Test,103 config = ResolvedTestConfig.default.copy(tags = setOf(Dummy, NoUse))104 )105 val c = ProjectConfiguration()106 c.includeTestScopeAffixes = true107 DefaultDisplayNameFormatter(c).format(tc) shouldBe "prefixfoo"108 }109 test("name should include suffix if affixes are included by default") {110 val tc = TestCase(111 descriptor = SpecWithDisplayName::class.toDescriptor().append("f:test"),112 name = TestName(null, "foo", "suffix", true),113 spec = SpecWithDisplayName(),114 test = {},115 source = sourceRef(),116 type = TestType.Test,117 config = ResolvedTestConfig.default.copy(tags = setOf(Dummy, NoUse))118 )119 DefaultDisplayNameFormatter(ProjectConfiguration()).format(tc) shouldBe "foosuffix"120 }121 test("name should include suffix if affixes are excluded by default but enabled in config") {122 val tc = TestCase(123 descriptor = SpecWithDisplayName::class.toDescriptor().append("f:test"),124 name = TestName(null, "foo", "suffix", false),125 spec = SpecWithDisplayName(),126 test = {},127 source = sourceRef(),128 type = TestType.Test,129 config = ResolvedTestConfig.default.copy(tags = setOf(Dummy, NoUse))130 )131 val c = ProjectConfiguration()132 c.includeTestScopeAffixes = true133 DefaultDisplayNameFormatter(c).format(tc) shouldBe "foosuffix"134 }135 }136}137object Dummy : Tag()138object NoUse : Tag()139@DisplayName("ZZZZZ")140private class SpecWithDisplayName : FunSpec({141 test("a") { }142})...

Full Screen

Full Screen

resolveConfig.kt

Source:resolveConfig.kt Github

copy

Full Screen

...3import io.kotest.core.spec.Spec4import io.kotest.core.test.Enabled5import io.kotest.core.test.EnabledOrReasonIf6import io.kotest.core.test.TestCase7import io.kotest.core.test.config.ResolvedTestConfig8import io.kotest.core.test.config.UnresolvedTestConfig9import io.kotest.engine.tags.tags10import kotlin.time.Duration11/**12 * Accepts an [UnresolvedTestConfig] and returns a [ResolvedTestConfig] by completing13 * any nulls in the unresolved config with defaults from the [spec] or [ProjectConfiguration].14 */15internal fun resolveConfig(16 config: UnresolvedTestConfig?,17 xdisabled: Boolean?,18 parent: TestCase?,19 spec:Spec,20 configuration: ProjectConfiguration21): ResolvedTestConfig {22 val defaultTestConfig = spec.defaultTestConfig23 ?: spec.defaultTestCaseConfig()24 ?: configuration.defaultTestConfig25 val enabled: EnabledOrReasonIf = { testCase ->26 when {27 // if xdisabled we always override any other enabled/disabled flags28 xdisabled == true -> Enabled.disabled("Disabled by xmethod")29 config?.enabled == false -> Enabled.disabled("Disabled by enabled flag in config")30 config?.enabledIf != null -> if (config.enabledIf!!.invoke(testCase)) Enabled.enabled else Enabled.disabled("Disabled by enabledIf flag in config")31 config?.enabledOrReasonIf != null -> config.enabledOrReasonIf!!.invoke(testCase)32 !defaultTestConfig.enabled -> Enabled.disabled33 !defaultTestConfig.enabledIf.invoke(testCase) -> Enabled.disabled34 else -> defaultTestConfig.enabledOrReasonIf.invoke(testCase)35 }36 }37 val timeout: Duration? = config?.timeout38 ?: parent?.config?.timeout39 ?: spec.timeout?.toMillis()40 ?: spec.timeout()?.toMillis()41 ?: defaultTestConfig.timeout42 ?: configuration.timeout?.toMillis()43 val threads = config?.threads44 ?: spec.threads45 ?: spec.threads()46 ?: defaultTestConfig.threads47 val invocations = config?.invocations48 ?: defaultTestConfig.invocations49 val invocationTimeout: Duration? = config?.invocationTimeout50 ?: parent?.config?.invocationTimeout51 ?: spec.invocationTimeout?.toMillis()52 ?: spec.invocationTimeout()?.toMillis()53 ?: defaultTestConfig.invocationTimeout54 ?: configuration.invocationTimeout?.toMillis()55 val extensions = (config?.listeners ?: emptyList()) +56 (config?.extensions ?: emptyList()) +57 defaultTestConfig.extensions +58 defaultTestConfig.listeners59 return ResolvedTestConfig(60 enabled = enabled,61 threads = threads,62 invocations = invocations,63 timeout = timeout,64 invocationTimeout = invocationTimeout,65 tags = (config?.tags ?: emptySet()) + (defaultTestConfig.tags) + (parent?.config?.tags ?: emptySet()) + spec.tags() + spec.appliedTags() + spec::class.tags(),66 extensions = extensions,67 failfast = config?.failfast ?: parent?.config?.failfast ?: spec.failfast ?: configuration.failfast,68 severity = config?.severity ?: parent?.config?.severity ?: spec.severity ?: configuration.severity,69 assertSoftly = config?.assertSoftly ?: parent?.config?.assertSoftly ?:spec.assertSoftly ?: configuration.globalAssertSoftly,70 assertionMode = config?.assertionMode ?: parent?.config?.assertionMode ?: spec.assertions ?: spec.assertionMode() ?: configuration.assertionMode,71 coroutineDebugProbes = config?.coroutineDebugProbes ?: parent?.config?.coroutineDebugProbes ?:spec.coroutineDebugProbes ?: configuration.coroutineDebugProbes,72 testCoroutineDispatcher = config?.testCoroutineDispatcher ?: parent?.config?.testCoroutineDispatcher ?: spec.testCoroutineDispatcher ?: configuration.testCoroutineDispatcher,73 coroutineTestScope = config?.coroutineTestScope ?: parent?.config?.coroutineTestScope ?: spec.coroutineTestScope ?: configuration.coroutineTestScope,...

Full Screen

Full Screen

TestTimeoutAfterTestListenerTest.kt

Source:TestTimeoutAfterTestListenerTest.kt Github

copy

Full Screen

...8import io.kotest.core.spec.style.FunSpec9import io.kotest.core.test.TestCase10import io.kotest.core.test.TestResult11import io.kotest.core.test.TestType12import io.kotest.core.test.config.ResolvedTestConfig13import io.kotest.engine.concurrency.NoopCoroutineDispatcherFactory14import io.kotest.engine.test.NoopTestCaseExecutionListener15import io.kotest.engine.test.TestCaseExecutor16import io.kotest.engine.test.scopes.NoopTestScope17import io.kotest.matchers.shouldBe18import kotlinx.coroutines.DelicateCoroutinesApi19import kotlinx.coroutines.Dispatchers20import kotlinx.coroutines.delay21import kotlinx.coroutines.withContext22import java.util.concurrent.atomic.AtomicInteger23import kotlin.time.Duration.Companion.milliseconds24@DelicateCoroutinesApi25@Suppress("BlockingMethodInNonBlockingContext")26class TestTimeoutAfterTestListenerTest : FunSpec() {27 init {28 test("tests that timeout during a blocking operation should still run the 'after test' listeners").config(29 timeout = 10000.milliseconds,30 blockingTest = true,31 ) {32 val blockingCount = AtomicInteger(0)33 // this listener will flick the flag to true, so we know it ran34 val listener = object : AfterTestListener {35 override suspend fun afterTest(testCase: TestCase, result: TestResult) {36 blockingCount.incrementAndGet()37 }38 }39 val tc = TestCase(40 descriptor = TestTimeoutAfterTestListenerTest::class.toDescriptor().append("wibble"),41 name = TestName("wibble"),42 spec = this@TestTimeoutAfterTestListenerTest,43 test = { Thread.sleep(1000000) },44 source = sourceRef(),45 type = TestType.Container,46 parent = null,47 config = ResolvedTestConfig.default.copy(48 timeout = 1.milliseconds,49 extensions = listOf(listener),50 blockingTest = true51 ),52 )53 val executor = TestCaseExecutor(NoopTestCaseExecutionListener, NoopCoroutineDispatcherFactory, ProjectConfiguration())54 // needs to run on a separate thread, so we don't interrupt our own thread55 withContext(Dispatchers.IO) {56 executor.execute(tc, NoopTestScope(testCase, coroutineContext))57 }58 blockingCount.get() shouldBe 159 }60 test("tests which timeout during a suspending operation should still run the 'after test' listeners").config(61 timeout = 10000.milliseconds62 ) {63 val suspendingCount = AtomicInteger(0)64 // this listener will flick the flag to true, so we know it ran65 val listener = object : AfterTestListener {66 override suspend fun afterAny(testCase: TestCase, result: TestResult) {67 suspendingCount.incrementAndGet()68 }69 }70 val tc = TestCase(71 descriptor = TestTimeoutAfterTestListenerTest::class.toDescriptor().append("wobble"),72 name = TestName("wobble"),73 spec = this@TestTimeoutAfterTestListenerTest,74 test = { delay(1000000) },75 source = sourceRef(),76 type = TestType.Container,77 parent = null,78 config = ResolvedTestConfig.default.copy(79 timeout = 1.milliseconds,80 extensions = listOf(listener),81 blockingTest = false82 ),83 )84 val executor = TestCaseExecutor(NoopTestCaseExecutionListener, NoopCoroutineDispatcherFactory, ProjectConfiguration())85 // needs to run on a separate thread, so we don't interrupt our own thread86 withContext(Dispatchers.IO) {87 executor.execute(tc, NoopTestScope(testCase, coroutineContext))88 }89 suspendingCount.get() shouldBe 190 }91 }92}...

Full Screen

Full Screen

TeamCityListenerIgnoredTestsEndToEndTest.kt

Source:TeamCityListenerIgnoredTestsEndToEndTest.kt Github

copy

Full Screen

...9//import io.kotest.core.test.Enabled10//import io.kotest.core.test.TestCase11//import io.kotest.core.test.TestResult12//import io.kotest.core.test.TestType13//import io.kotest.core.test.config.ResolvedTestConfig14//import io.kotest.engine.listener.TeamCityTestEngineListener15//import io.kotest.extensions.system.captureStandardOut16//import io.kotest.matchers.shouldBe17//import kotlin.reflect.KClass18//19//class TeamCityListenerIgnoredTestsEndToEndTest : FunSpec() {20//21// private val kclass: KClass<out Spec> = TeamCityListenerIgnoredTestsEndToEndTest::class22//23// private val testCase1 = TestCase(24// descriptor = kclass.toDescriptor().append("disabled test"),25// name = TestName("disabled test"),26// spec = this,27// test = { },28// source = sourceRef(),29// type = TestType.Test,30// config = ResolvedTestConfig.default.copy(enabled = { Enabled.disabled }),31// factoryId = null,32// )33//34// private val testCase2 = testCase1.copy(35// descriptor = kclass.toDescriptor().append("disabled container"),36// type = TestType.Container,37// )38//39// init {40// test("an inactive spec should have tests marked as ignored") {41// val out = captureStandardOut {42// val listener = TeamCityTestEngineListener()43// listener.specEnter(kclass)44// listener.specInactive(...

Full Screen

Full Screen

TestTimeoutTest.kt

Source:TestTimeoutTest.kt Github

copy

Full Screen

...6import io.kotest.core.source.sourceRef7import io.kotest.core.spec.style.FunSpec8import io.kotest.core.test.TestCase9import io.kotest.core.test.TestType10import io.kotest.core.test.config.ResolvedTestConfig11import io.kotest.engine.concurrency.NoopCoroutineDispatcherFactory12import io.kotest.engine.test.NoopTestCaseExecutionListener13import io.kotest.engine.test.TestCaseExecutor14import io.kotest.engine.test.scopes.NoopTestScope15import kotlinx.coroutines.DelicateCoroutinesApi16import kotlinx.coroutines.Dispatchers17import kotlinx.coroutines.delay18import kotlinx.coroutines.withContext19import kotlin.time.Duration.Companion.milliseconds20@DelicateCoroutinesApi21@Suppress("BlockingMethodInNonBlockingContext")22class TestTimeoutTest : FunSpec() {23 init {24 test("tests that timeout during a blocking operation should be interrupted").config(25 timeout = 10000.milliseconds,26 blockingTest = true,27 ) {28 val tc = TestCase(29 descriptor = TestTimeoutTest::class.toDescriptor().append("wibble"),30 name = TestName("wibble"),31 spec = this@TestTimeoutTest,32 test = { Thread.sleep(10000000) },33 source = sourceRef(),34 type = TestType.Container,35 parent = null,36 config = ResolvedTestConfig.default.copy(37 timeout = 1.milliseconds,38 blockingTest = true39 ),40 )41 val executor = TestCaseExecutor(NoopTestCaseExecutionListener, NoopCoroutineDispatcherFactory, ProjectConfiguration())42 // needs to run on a separate thread, so we don't interrupt our own thread43 withContext(Dispatchers.IO) {44 executor.execute(tc, NoopTestScope(testCase, coroutineContext))45 }46 }47 test("tests which timeout during a suspending operation should be cancelled").config(48 timeout = 10000.milliseconds49 ) {50 val tc = TestCase(51 descriptor = TestTimeoutTest::class.toDescriptor().append("wobble"),52 name = TestName("wobble"),53 spec = this@TestTimeoutTest,54 test = { delay(1000000) },55 source = sourceRef(),56 type = TestType.Container,57 parent = null,58 config = ResolvedTestConfig.default.copy(59 timeout = 1.milliseconds,60 ),61 )62 val executor = TestCaseExecutor(NoopTestCaseExecutionListener, NoopCoroutineDispatcherFactory, ProjectConfiguration())63 // needs to run on a separate thread, so we don't interrupt our own thread64 withContext(Dispatchers.IO) {65 executor.execute(tc, NoopTestScope(testCase, coroutineContext))66 }67 }68 }69}...

Full Screen

Full Screen

TestCase.kt

Source:TestCase.kt Github

copy

Full Screen

...4import io.kotest.core.factory.FactoryId5import io.kotest.core.names.TestName6import io.kotest.core.source.sourceRef7import io.kotest.core.spec.Spec8import io.kotest.core.test.config.ResolvedTestConfig9/**10 * A [TestCase] describes a test lambda at runtime.11 *12 * It contains a reference back to the [Spec] instance in which it13 * is being executed.14 *15 * It also captures a closure of the body of the test case.16 * This is a function which is invoked with a [TestScope].17 * The context is used so that the test function can, at runtime,18 * register nested tests with the test engine. This allows19 * nested tests to be executed lazily as required, rather20 * than when the [Spec] instance is created.21 *22 * A test can be nested inside other tests if the [Spec] supports it.23 *24 * For example, in the FunSpec we only allow top level tests.25 *26 * test("this is a test") { }27 *28 * And in WordSpec we allow two levels of tests.29 *30 * "a string" should {31 * "return the length" {32 * }33 * }34 *35 */36data class TestCase(37 // parseable, stable, consistent identifer for this test element38 val descriptor: Descriptor.TestDescriptor,39 // the name of the test as entered by the user40 val name: TestName,41 // the spec instance that contains this testcase42 val spec: Spec,43 // a closure of the test function44 val test: suspend TestScope.() -> Unit,45 // a reference to the source code where this test case was defined46 val source: SourceRef = sourceRef(),47 // the type specifies if this test case is permitted to contain nested tests (container)48 val type: TestType,49 // resolved config at runtime for this test50 val config: ResolvedTestConfig = ResolvedTestConfig.default,51 // an optional factory id which is used to indicate which factory (if any) generated this test case.52 val factoryId: FactoryId? = null,53 // the parent test case for this test at runtime, or null54 val parent: TestCase? = null,55) {56 @Deprecated("Use testCase.name or testCase.descriptor. This was deprecated in 5.0.")57 val displayName: String = descriptor.id.value58}59/**60 * Returns true if this test is focused.61 *62 * A focused test case is one which is defined at the top level and has a f: prefix63 */64fun TestCase.isFocused() = this.parent == null && name.focus...

Full Screen

Full Screen

DynamicRootTest.kt

Source:DynamicRootTest.kt Github

copy

Full Screen

2import io.kotest.core.source.SourceRef3import io.kotest.core.names.TestName4import io.kotest.core.spec.Spec5import io.kotest.core.test.TestCase6import io.kotest.core.test.config.ResolvedTestConfig7import io.kotest.core.test.TestScope8import io.kotest.core.test.TestType9/**10 * A [DynamicRootTest] is an intermediate test state held by a factory. Once the factory is added to a11 * [Spec] and the spec is created, the factories dynamic tests will be added to the spec12 * as fully fledged [TestCase]s.13 */14data class DynamicRootTest(15 val name: TestName,16 val test: suspend TestScope.() -> Unit,17 val config: ResolvedTestConfig,18 val type: TestType,19 val source: SourceRef,20 val factoryId: FactoryId21)22fun DynamicRootTest.addPrefix(prefix: String): DynamicRootTest = copy(name = name.copy(testName = "$prefix $name"))...

Full Screen

Full Screen

ResolvedTestConfig

Using AI Code Generation

copy

Full Screen

1import io.kotest.core.test.config.ResolvedTestConfig2ResolvedTestConfig(3import io.kotest.core.test.config.ResolvedTestConfig4ResolvedTestConfig(5import io.kotest.core.test.config.ResolvedTestConfig6ResolvedTestConfig(7import io.kotest.core.test.config.ResolvedTestConfig8ResolvedTestConfig(9import io.kotest.core.test.config.ResolvedTestConfig10ResolvedTestConfig(11import io.kotest.core.test.config.ResolvedTestConfig12ResolvedTestConfig(13import io.kotest.core.test.config.ResolvedTestConfig14ResolvedTestConfig(15import io.kotest.core.test.config.ResolvedTestConfig16ResolvedTestConfig(17import io.kotest.core.test.config.ResolvedTestConfig18ResolvedTestConfig(19import io.kotest.core.test.config.ResolvedTestConfig20ResolvedTestConfig(21import io.kotest.core.test.config.ResolvedTestConfig22ResolvedTestConfig(23import io.kotest.core.test.config.ResolvedTestConfig24ResolvedTestConfig(25import io.kotest.core.test.config.ResolvedTestConfig26ResolvedTestConfig(27import io.kotest.core.test.config.ResolvedTestConfig28ResolvedTestConfig(

Full Screen

Full Screen

ResolvedTestConfig

Using AI Code Generation

copy

Full Screen

1 override fun createTestConfig(): ResolvedTestConfig = ResolvedTestConfig(2 tags = emptySet(),3 extensions = emptyList()4}5System.setProperty("user.dir", System.getProperty("user.dir"))6System.setProperty("user.dir", System.getProperty("user.dir"))

Full Screen

Full Screen

ResolvedTestConfig

Using AI Code Generation

copy

Full Screen

1val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )2val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )3val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )4val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )5val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )6val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )7val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )8val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )9val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )10val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )11val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )12val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )13val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )14val config = ResolvedTestConfig ( defaultConfig , testConfig , projectConfig )

Full Screen

Full Screen

ResolvedTestConfig

Using AI Code Generation

copy

Full Screen

1 val resolvedConfig = ResolvedTestConfig(this)2 val resolvedConfig = ResolvedTestConfig(this)3 val resolvedConfig = ResolvedTestConfig(this)4 val resolvedConfig = ResolvedTestConfig(this)5 val resolvedConfig = ResolvedTestConfig(this)6 val resolvedConfig = ResolvedTestConfig(this)7 val resolvedConfig = ResolvedTestConfig(this)8 val resolvedConfig = ResolvedTestConfig(this)9 val resolvedConfig = ResolvedTestConfig(this)10 val resolvedConfig = ResolvedTestConfig(this)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful