Best Kotest code snippet using io.kotest.core.config.ProjectConfiguration.extensions
IsEnabledTest.kt
Source:IsEnabledTest.kt
...5import io.kotest.core.config.ProjectConfiguration6import io.kotest.core.descriptors.Descriptor7import io.kotest.core.descriptors.append8import io.kotest.core.descriptors.toDescriptor9import io.kotest.core.extensions.EnabledExtension10import io.kotest.core.extensions.TagExtension11import io.kotest.core.filter.TestFilter12import io.kotest.core.filter.TestFilterResult13import io.kotest.core.filter.toTestFilterResult14import io.kotest.core.names.TestName15import io.kotest.core.spec.style.FunSpec16import 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(),...
TestEngineLauncher.kt
Source:TestEngineLauncher.kt
...4import io.kotest.common.runPromise5import io.kotest.core.TagExpression6import io.kotest.core.config.AbstractProjectConfig7import io.kotest.core.config.ProjectConfiguration8import io.kotest.core.extensions.Extension9import io.kotest.core.project.TestSuite10import io.kotest.core.spec.Spec11import io.kotest.core.spec.SpecRef12import io.kotest.engine.config.ConfigManager13import io.kotest.engine.config.detectAbstractProjectConfigs14import io.kotest.engine.config.loadProjectConfigFromClassname15import io.kotest.engine.extensions.SpecifiedTagsTagExtension16import io.kotest.engine.listener.NoopTestEngineListener17import io.kotest.engine.listener.PinnedSpecTestEngineListener18import io.kotest.engine.listener.TeamCityTestEngineListener19import io.kotest.engine.listener.TestEngineListener20import io.kotest.engine.listener.ThreadSafeTestEngineListener21import io.kotest.mpp.log22import kotlin.reflect.KClass23/**24 * A builder class for creating and executing tests via the [TestEngine].25 *26 * Entry point for tests generated through the compiler plugins, and so the27 * public api cannot have breaking changes.28 */29class TestEngineLauncher(30 private val listener: TestEngineListener,31 private val projectConfiguration: ProjectConfiguration,32 private val configs: List<AbstractProjectConfig>,33 private val refs: List<SpecRef>,34 private val tagExpression: TagExpression?,35) {36 constructor() : this(37 NoopTestEngineListener,38 ProjectConfiguration(),39 emptyList(),40 emptyList(),41 null,42 )43 constructor(listener: TestEngineListener) : this(44 listener,45 ProjectConfiguration(),46 emptyList(),47 emptyList(),48 null,49 )50 /**51 * Convenience function to be called by the native code gen to set up the TeamCity listener.52 */53 fun withTeamCityListener(): TestEngineLauncher {54 return withListener(TeamCityTestEngineListener())55 }56 /**57 * Replace the listener with the given value.58 */59 fun withListener(listener: TestEngineListener): TestEngineLauncher {60 return TestEngineLauncher(61 listener = listener,62 projectConfiguration = projectConfiguration,63 configs = configs,64 refs = refs,65 tagExpression = tagExpression,66 )67 }68 fun withSpecs(vararg specs: Spec): TestEngineLauncher {69 return TestEngineLauncher(70 listener = listener,71 projectConfiguration = projectConfiguration,72 configs = configs,73 refs = specs.toList().map { SpecRef.Singleton(it) },74 tagExpression = tagExpression,75 )76 }77 fun withClasses(vararg specs: KClass<out Spec>): TestEngineLauncher = withClasses(specs.toList())78 fun withClasses(specs: List<KClass<out Spec>>): TestEngineLauncher {79 return TestEngineLauncher(80 listener = listener,81 projectConfiguration = projectConfiguration,82 configs = configs,83 refs = specs.toList().map { SpecRef.Reference(it) },84 tagExpression = tagExpression,85 )86 }87 /**88 * Adds a [AbstractProjectConfig] that was detected by the compiler plugin.89 */90 @Deprecated("Use withProjectConfig. Will be removed once compiler plugins are updated")91 fun withConfig(vararg projectConfig: AbstractProjectConfig): TestEngineLauncher {92 return withProjectConfig(*projectConfig)93 }94 /**95 * Adds a [AbstractProjectConfig] that was detected by the compiler plugin.96 */97 fun withProjectConfig(vararg projectConfig: AbstractProjectConfig): TestEngineLauncher {98 return TestEngineLauncher(99 listener = listener,100 projectConfiguration = projectConfiguration,101 configs = configs + projectConfig,102 refs = refs,103 tagExpression = tagExpression,104 )105 }106 fun withTagExpression(expression: TagExpression?): TestEngineLauncher {107 return TestEngineLauncher(108 listener = listener,109 projectConfiguration = projectConfiguration,110 configs = configs,111 refs = refs,112 tagExpression = expression,113 )114 }115 /**116 * Returns a copy of this launcher with the given [extensions] added to the configuration.117 *118 * Note: If after invoking this method, the [withConfiguration] is invoked, then any changes119 * here will be lost.120 */121 fun withExtensions(vararg extensions: Extension): TestEngineLauncher = withExtensions(extensions.toList())122 /**123 * Returns a copy of this launcher with the given [extensions] added to the configuration.124 *125 * Note: If after invoking this method, the [withConfiguration] is invoked, then any changes126 * here will be lost.127 */128 fun withExtensions(extensions: List<Extension>): TestEngineLauncher {129 extensions.forEach { projectConfiguration.registry.add(it) }130 return this131 }132 fun withConfiguration(configuration: ProjectConfiguration): TestEngineLauncher {133 return TestEngineLauncher(134 listener = listener,135 projectConfiguration = configuration,136 configs = configs,137 refs = refs,138 tagExpression = tagExpression,139 )140 }141 fun toConfig(): TestEngineConfig {142 // if the engine was configured with explicit tags, we register those via a tag extension143 tagExpression?.let { projectConfiguration.registry.add(SpecifiedTagsTagExtension(it)) }...
ActionTest.kt
Source:ActionTest.kt
1package fi.epicbot.toster.model2import fi.epicbot.toster.executor.android.AndroidExecutor3import fi.epicbot.toster.report.model.Common4import fi.epicbot.toster.report.model.GfxInfo5import fi.epicbot.toster.report.model.Memory6import fi.epicbot.toster.report.model.ReportAction7import fi.epicbot.toster.report.model.ReportScreen8import fi.epicbot.toster.report.model.Screenshot9import io.kotest.core.config.ProjectConfiguration10import io.kotest.core.spec.SpecRef11import io.kotest.core.spec.style.AnnotationSpec12import io.kotest.core.spec.style.BehaviorSpec13import io.kotest.core.spec.style.DescribeSpec14import io.kotest.core.test.TestScope15import io.kotest.engine.TestEngineLauncher16import io.kotest.engine.listener.CollectingTestEngineListener17import io.kotest.matchers.shouldBe18import io.mockk.mockk19private val reportScreen = ReportScreen("test report")20private val actionExecutor = AndroidExecutor(21 "serial", mockk(relaxed = true), mockk(relaxed = true),22 mockk(relaxed = true), mockk(relaxed = true),23)24private const val IMAGE_PREFIX = "prefix"25private open class ActionTestSpec(action: Action, reportScreen: ReportScreen) : DescribeSpec({26 describe(action.title()) {27 actionExecutor.imagePrefix = IMAGE_PREFIX28 action.runAction(29 actionExecutor,30 reportScreen,31 true,32 )33 }34})35private class ActionTestData(36 val name: String,37 val action: Action,38 val reportAction: ReportAction,39 val reportScreenNumberCheck: suspend TestScope.() -> Unit,40 val reportScreenModelCheck: suspend TestScope.() -> Unit,41)42private val data = listOf(43 ActionTestData(44 "Clear app data",45 Action.ClearAppData,46 Common(0, "Clear app data", 0, 4),47 {48 reportScreen.common.size shouldBe 149 },50 {51 val actualCommon = reportScreen.common[0]52 actualCommon.name shouldBe "Clear app data"53 }54 ),55 ActionTestData(56 "Take screenshot",57 Action.TakeScreenshot("name"),58 Screenshot(1, "name", 0, 4, "prefix", "path"),59 {60 reportScreen.screenshots.size shouldBe 161 },62 {63 val actualCommon = reportScreen.screenshots[0]64 actualCommon.name shouldBe "Take screenshot"65 }66 ),67 ActionTestData(68 "Take gfxinfo",69 Action.TakeGfxInfo,70 GfxInfo(0, "name", 0, 4, emptyMap()),71 {72 reportScreen.gfxInfo.size shouldBe 173 },74 {75 val actualCommon = reportScreen.gfxInfo[0]76 actualCommon.name shouldBe "Take gfxinfo"77 }78 ),79 ActionTestData(80 "Take memory allocation",81 Action.TakeMemoryAllocation,82 Memory(0, "name", 0, 4, emptyMap()),83 {84 reportScreen.memory.size shouldBe 185 },86 {87 val actualCommon = reportScreen.memory[0]88 actualCommon.name shouldBe "Take memory allocation"89 }90 ),91)92class ActionTest : BehaviorSpec({93 @AnnotationSpec.BeforeEach94 fun beforeTest() {95 reportScreen.common.clear()96 reportScreen.screenshots.clear()97 reportScreen.gfxInfo.clear()98 reportScreen.memory.clear()99 }100 data.forEach { actionTestData ->101 Given("Action ${actionTestData.action.title()}") {102 val collector = CollectingTestEngineListener()103 val projectConfiguration = ProjectConfiguration()104 When("execute action") {105 val ref = SpecRef.Function({106 ActionTestSpec(actionTestData.action, reportScreen)107 }, ActionTestSpec::class)108 TestEngineLauncher(collector, projectConfiguration, emptyList(), listOf(ref), null)109 .withExtensions()110 .launch()111 Then("check test name") {112 collector.result(actionTestData.name)?.isSuccess shouldBe true113 }114 Then("check report", actionTestData.reportScreenNumberCheck)115 Then("check model", actionTestData.reportScreenModelCheck)116 }117 }118 }119})...
ApplyConfigTest.kt
Source:ApplyConfigTest.kt
...6import io.kotest.core.spec.Isolate7import io.kotest.core.spec.style.FunSpec8import io.kotest.engine.config.applyConfigFromProjectConfig9import io.kotest.engine.config.applyConfigFromSystemProperties10import io.kotest.extensions.system.OverrideMode11import io.kotest.extensions.system.withEnvironment12import io.kotest.extensions.system.withSystemProperty13import io.kotest.matchers.shouldBe14private const val key = KotestEngineProperties.logLevel15@Isolate16class ApplyConfigTest : FunSpec({17 test("log level can come from sys props") {18 val expected = LogLevel.Info19 val config = ProjectConfiguration()20 config.logLevel shouldBe LogLevel.Off21 withEnvironment(key, LogLevel.Error.name, OverrideMode.SetOrOverride) {22 withSystemProperty(key, expected.name, OverrideMode.SetOrOverride) {23 applyConfigFromSystemProperties(config)24 }25 }26 config.logLevel shouldBe expected...
RuntimeTagExtensionTest.kt
Source:RuntimeTagExtensionTest.kt
1package com.sksamuel.kotest.engine.tags2import io.kotest.assertions.fail3import io.kotest.core.Tag4import io.kotest.core.config.ProjectConfiguration5import io.kotest.core.extensions.RuntimeTagExpressionExtension6import io.kotest.core.extensions.RuntimeTagExtension7import io.kotest.core.annotation.Isolate8import io.kotest.core.spec.style.FunSpec9import io.kotest.core.spec.style.StringSpec10import io.kotest.engine.TestEngineLauncher11import io.kotest.engine.listener.NoopTestEngineListener12import io.kotest.matchers.collections.shouldBeEmpty13object MyRuntimeExcludedTag : Tag()14@Isolate15class RuntimeTagExtensionTest : StringSpec() {16 init {17 "Tests with tag should not execute when excluded by a RuntimeTagExtension" {18 val c = ProjectConfiguration()19 c.registry.add(RuntimeTagExtension(included = emptySet(), excluded = setOf(MyRuntimeExcludedTag)))20 TestEngineLauncher(NoopTestEngineListener)...
enabled.kt
Source:enabled.kt
1package io.kotest.engine.test.status2import io.kotest.core.config.ProjectConfiguration3import io.kotest.core.extensions.EnabledExtension4import io.kotest.core.test.Enabled5import io.kotest.core.test.TestCase6import io.kotest.engine.spec.SpecExtensions7import io.kotest.engine.tags.runtimeTags8/**9 * Returns [Enabled.enabled] if the given [TestCase] is enabled based on default rules10 * from [isEnabledInternal] or any registered [EnabledExtension]s.11 */12suspend fun TestCase.isEnabled(conf: ProjectConfiguration): Enabled {13 val internal = isEnabledInternal(conf)14 return if (!internal.isEnabled) {15 internal16 } else {17 val disabled = SpecExtensions(conf.registry)18 .extensions(spec)19 .filterIsInstance<EnabledExtension>()20 .map { it.isEnabled(descriptor) }21 .firstOrNull { it.isDisabled }22 disabled ?: Enabled.enabled23 }24}25/**26 * Determines enabled status by using [TestEnabledExtension]s.27 */28internal fun TestCase.isEnabledInternal(conf: ProjectConfiguration): Enabled {29 val extensions = listOf(30 TestConfigEnabledExtension,31 TagsEnabledExtension(conf.runtimeTags()),32 TestFilterEnabledExtension(conf.registry),33 SystemPropertyTestFilterEnabledExtension,34 FocusEnabledExtension,35 BangTestEnabledExtension,36 SeverityLevelEnabledExtension,37 )38 return extensions.fold(Enabled.enabled) { acc, ext -> if (acc.isEnabled) ext.isEnabled(this) else acc }39}...
SystemPropertyConfigClassTest.kt
Source:SystemPropertyConfigClassTest.kt
...4import io.kotest.core.internal.KotestEngineProperties5import io.kotest.core.spec.style.FunSpec6import io.kotest.engine.TestEngineLauncher7import io.kotest.engine.listener.CollectingTestEngineListener8import io.kotest.extensions.system.withSystemProperty9import io.kotest.matchers.shouldBe10import kotlinx.coroutines.delay11class SystemPropertyConfigClassTest : FunSpec() {12 init {13 test("system property should be used for config") {14 withSystemProperty(15 KotestEngineProperties.configurationClassName,16 "com.sksamuel.kotest.config.classname.WibbleConfig"17 ) {18 val projectConfiguration = ProjectConfiguration()19 val collector = CollectingTestEngineListener()20 TestEngineLauncher(collector, projectConfiguration, emptyList(), emptyList(), null)21 .withClasses(FooTest::class)22 .launch()...
ProjectConfiguration.kt
Source:ProjectConfiguration.kt
1package ru.iopump.kotest.allure2import io.kotest.core.config.AbstractProjectConfig3import io.kotest.core.extensions.Extension4import ru.iopump.kotest.allure.api.KotestAllureExecution.EXECUTION_START_CALLBACK5import ru.iopump.kotest.allure.api.KotestAllureExecution.setUpFixture6object ProjectConfiguration : AbstractProjectConfig() {7 override val parallelism: Int = 28 init {9 EXECUTION_START_CALLBACK = { it.setUpFixture("Project Set Up") }10 }11 override fun extensions(): List<Extension> = listOf(12 KotestAllureListener13 )14}...
extensions
Using AI Code Generation
1import io.kotest.core.config.ProjectConfiguration2object ProjectConfig : ProjectConfiguration() {3override fun extensions() = listOf(EmailReporter())4}5import io.kotest.core.extensions.SpecExtension6import io.kotest.core.spec.Spec7import io.kotest.core.spec.style.StringSpec8import io.kotest.core.test.TestCase9import io.kotest.core.test.TestResult10import java.io.File11class SpecExtensionExample : StringSpec() {12override fun extensions() = listOf(CustomSpecExtension())13init {14"test case 1" {15println("test case 1")16}17"test case 2" {18println("test case 2")19}20}21}22class CustomSpecExtension : SpecExtension {23override suspend fun intercept(spec: Spec, process: suspend (Spec) -> Unit) {24println("Before Spec: ${spec::class.simpleName}")25process(spec)26println("After Spec: ${spec::class.simpleName}")27}28override suspend fun intercept(spec: Spec, testCase: TestCase, process: suspend (TestCase, suspend (TestCase, TestResult) -> TestResult) -> TestResult): TestResult {29println("Before test case: ${testCase.description.testName}")30val result = process(testCase) { tc, tr ->31println("After test case: ${tc.description.testName}")32}33println("After test case: ${testCase.description.testName} with result ${result.error}")34}35}36import io.kotest.core.extensions.TestCaseExtension37import io.kotest.core.spec.Spec38import io.kotest.core.spec.style.StringSpec39import io.kotest.core.test.TestCase40import io.kotest.core.test.TestResult41import java.io.File42class TestCaseExtensionExample : StringSpec() {43override fun extensions() = listOf(CustomTestCaseExtension())44init {45"test case 1" {46println("test case 1")47}48"test case 2" {49println("test case 2")50}51}52}53class CustomTestCaseExtension : TestCaseExtension {54override suspend fun intercept(spec: Spec, testCase: TestCase, process: suspend (TestCase, suspend (TestCase, TestResult) -> TestResult) -> TestResult): TestResult {55println("Before test case: ${testCase.description.testName}")56val result = process(testCase) { tc,
extensions
Using AI Code Generation
1class MyProjectConfig : ProjectConfiguration() {2 override fun extensions(): List<Extension> {3 return listOf(4 }5}6class MyProjectConfig : ProjectConfiguration() {7 override fun extensions(): List<Extension> {8 return listOf(9 }10}11class MyProjectConfig : ProjectConfiguration() {12 override fun extensions(): List<Extension> {13 return listOf(14 }15}16class MyProjectConfig : ProjectConfiguration() {17 override fun extensions(): List<Extension> {18 return listOf(19 }20}21class MyProjectConfig : ProjectConfiguration() {22 override fun extensions(): List<Extension> {23 return listOf(24 }25}26class MyProjectConfig : ProjectConfiguration() {27 override fun extensions(): List<Extension> {28 return listOf(29 }30}31class MyProjectConfig : ProjectConfiguration() {32 override fun extensions(): List<Extension> {33 return listOf(34 }35}36class MyProjectConfig : ProjectConfiguration() {37 override fun extensions(): List<Extension> {38 return listOf(39 }40}
extensions
Using AI Code Generation
1 fun ProjectConfiguration.extensions() = ProjectExtensions(this)2 fun ProjectExtensions.setExtension(extension: Any) {3 }4 class MyProjectConfig : ProjectConfig() {5 init {6 extensions {7 setExtension(MyExtension())8 }9 }10 }11 class MyExtension : Extension {12 override fun intercept(13 process: suspend (Spec) -> Unit14 ) {15 println("Before Spec: ${spec::class.simpleName}")16 process(spec)17 println("After Spec: ${spec::class.simpleName}")18 }19 }20 @ProjectConfig(MyProjectConfig::class)21 class MySpec : FunSpec({22 test("test") {23 println("Test")24 }25 })
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!