How to use detectAbstractProjectConfigs method of io.kotest.engine.config.detectAbstractProjectConfigs class

Best Kotest code snippet using io.kotest.engine.config.detectAbstractProjectConfigs.detectAbstractProjectConfigs

TestEngineLauncher.kt

Source:TestEngineLauncher.kt Github

copy

Full Screen

...9import 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)) }144 return TestEngineConfig(145 listener = ThreadSafeTestEngineListener(146 PinnedSpecTestEngineListener(147 listener148 )149 ),150 interceptors = testEngineInterceptors(),151 configuration = ConfigManager.initialize(152 projectConfiguration,153 configs + detectAbstractProjectConfigs() + listOfNotNull(loadProjectConfigFromClassname())154 ),155 tagExpression,156 )157 }158 fun testSuite(): TestSuite = TestSuite(refs)159 /**160 * Launch the [TestEngine] in an existing coroutine without blocking.161 */162 suspend fun async(): EngineResult {163 log { "TestEngineLauncher: Launching Test Engine" }164 val engine = TestEngine(toConfig())165 return engine.execute(testSuite())166 }167 /**...

Full Screen

Full Screen

ConfigManager.kt

Source:ConfigManager.kt Github

copy

Full Screen

...49 * Scan the classpath for [AbstractProjectConfig] instances.50 *51 * Note: This will only have an effect on JVM targets.52 */53internal expect fun detectAbstractProjectConfigs(): List<AbstractProjectConfig>...

Full Screen

Full Screen

detectAbstractProjectConfigs.kt

Source:detectAbstractProjectConfigs.kt Github

copy

Full Screen

1package io.kotest.engine.config2import io.kotest.core.config.AbstractProjectConfig3import io.kotest.core.internal.KotestEngineProperties4import io.kotest.mpp.instantiateOrObject5internal actual fun detectAbstractProjectConfigs(): List<AbstractProjectConfig> {6 // this property is used to disable class path scanning for configurations7 if (System.getProperty(KotestEngineProperties.disableConfigurationClassPathScanning) == "true")8 return emptyList()9 return classgraph().scan().use { result ->10 result.getSubclasses(AbstractProjectConfig::class.java.name)11 .map { Class.forName(it.name) as Class<out AbstractProjectConfig> }12 .mapNotNull { instantiateOrObject(it).getOrNull() }13 }14}

Full Screen

Full Screen

applyConfigs.kt

Source:applyConfigs.kt Github

copy

Full Screen

...3import io.kotest.core.config.ProjectConfiguration4internal actual fun applyConfigFromSystemProperties(configuration: ProjectConfiguration) {}5internal actual fun applyConfigFromAutoScan(configuration: ProjectConfiguration) {}6internal actual fun applyPlatformDefaults(configuration: ProjectConfiguration) {}7internal actual fun detectAbstractProjectConfigs(): List<AbstractProjectConfig> = emptyList()8internal actual fun loadProjectConfigFromClassname(): AbstractProjectConfig? = null...

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.

Most used method in detectAbstractProjectConfigs

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful