How to use ProjectConfiguration.runtimeTags method of io.kotest.engine.tags.runtime class

Best Kotest code snippet using io.kotest.engine.tags.runtime.ProjectConfiguration.runtimeTags

dump.kt

Source: dump.kt Github

copy

Full Screen

1package io.kotest.engine.config2import io.kotest.core.config.ProjectConfiguration3import io.kotest.engine.tags.runtimeTags4import io.kotest.mpp.bestName5fun ProjectConfiguration.createConfigSummary(): String {6 val sb = StringBuilder()7 sb.buildOutput("Parallelization factor", parallelism.toString())8 sb.buildOutput("Concurrent specs", concurrentSpecs.toString())9 sb.buildOutput("Global concurrent tests", concurrentTests.toString())10 sb.buildOutput("Dispatcher affinity", dispatcherAffinity.toString())11 sb.buildOutput("Coroutine debug probe", coroutineDebugProbes.toString())12 sb.buildOutput("Spec execution order", specExecutionOrder.name)13 sb.buildOutput("Default test execution order", testCaseOrder.name)14 sb.buildOutput("Default test timeout", timeout.toString() + "ms")15 sb.buildOutput("Default test invocation timeout", invocationTimeout.toString() + "ms")16 if (projectTimeout != null)17 sb.buildOutput("Overall project timeout", projectTimeout.toString() + "ms")18 sb.buildOutput("Default isolation mode", isolationMode.name)19 sb.buildOutput("Global soft assertions", globalAssertSoftly.toString())20 sb.buildOutput("Write spec failure file", writeSpecFailureFile.toString())21 if (writeSpecFailureFile) {22 sb.buildOutput("Spec failure file path",23 specFailureFilePath.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() })24 }25 sb.buildOutput("Fail on ignored tests", failOnIgnoredTests.toString())26 sb.buildOutput("Fail on empty test suite", failOnEmptyTestSuite.toString())27 sb.buildOutput("Duplicate test name mode", duplicateTestNameMode.name)28 if (includeTestScopeAffixes != null)29 sb.buildOutput("Include test scope affixes", includeTestScopeAffixes.toString())30 sb.buildOutput("Remove test name whitespace", removeTestNameWhitespace.toString())31 sb.buildOutput("Append tags to test names", testNameAppendTags.toString())32 if (registry.isNotEmpty()) {33 sb.buildOutput("Extensions")34 registry.all().map(::mapClassName).forEach {35 sb.buildOutput(it, indentation = 1)36 }37 }38 runtimeTags().expression?.let { sb.buildOutput("Tags", it) }39 return sb.toString()40}41fun ProjectConfiguration.dumpProjectConfig() {42 println("~~~ Kotest Configuration ~~~")43 println(createConfigSummary())44}45private fun StringBuilder.buildOutput(key: String, value: String? = null, indentation: Int = 0) {46 if (indentation == 0) {47 append("-> ")48 } else {49 for (i in 0 until indentation) {50 append(" ")51 }52 append("- ")53 }54 append(key)55 value?.let { append(": $it") }56 append("\n")57}58private fun mapClassName(any: Any) = any::class.bestName()...

Full Screen

Full Screen

TestEngine.kt

Source: TestEngine.kt Github

copy

Full Screen

1package io.kotest.engine2import io.kotest.common.ExperimentalKotest3import io.kotest.common.KotestInternal4import io.kotest.common.Platform5import io.kotest.common.platform6import io.kotest.core.TagExpression7import io.kotest.core.config.ProjectConfiguration8import io.kotest.core.project.TestSuite9import io.kotest.engine.interceptors.EngineContext10import io.kotest.engine.interceptors.EngineInterceptor11import io.kotest.engine.listener.TestEngineListener12import io.kotest.engine.tags.runtimeTags13import io.kotest.mpp.Logger14data class EngineResult(val errors: List<Throwable>) {15 companion object {16 val empty = EngineResult(emptyList())17 }18 fun addError(t: Throwable): EngineResult {19 return EngineResult(errors + t)20 }21}22@KotestInternal23data class TestEngineConfig(24 val listener: TestEngineListener,25 val interceptors: List<EngineInterceptor>,26 val configuration: ProjectConfiguration,27 val explicitTags: TagExpression?,28)29/​**30 * Multiplatform Kotest Test Engine.31 */​32@KotestInternal33class TestEngine(private val config: TestEngineConfig) {34 private val logger = Logger(this::class)35 /​**36 * Starts execution of the given [TestSuite], intercepting calls via [EngineInterceptor]s.37 *38 * It is recommended that this method is not invoked, but instead the engine39 * is launched via the [TestEngineLauncher].40 */​41 @OptIn(KotestInternal::class, ExperimentalKotest::class)42 internal suspend fun execute(suite: TestSuite): EngineResult {43 logger.log { Pair(null, "Executing test suite with ${suite.specs.size} specs") }44 val innerExecute: suspend (EngineContext) -> EngineResult = { context ->45 val scheduler = when (platform) {46 Platform.JVM -> ConcurrentTestSuiteScheduler(47 config.configuration.concurrentSpecs ?: config.configuration.parallelism,48 context,49 )50 Platform.JS -> SequentialTestSuiteScheduler(context)51 Platform.Native -> SequentialTestSuiteScheduler(context)52 }53 scheduler.schedule(context.suite)54 }55 logger.log { Pair(null, "${config.interceptors.size} engine interceptors") }56 val execute = config.interceptors.foldRight(innerExecute) { extension, next ->57 { context -> extension.intercept(context, next) }58 }59 val tags = config.configuration.runtimeTags()60 logger.log { Pair(null, "TestEngine: Active tags: ${tags.expression}") }61 return execute(EngineContext(suite, config.listener, tags, config.configuration))62 }63}...

Full Screen

Full Screen

RequiresTagSpecInterceptor.kt

Source: RequiresTagSpecInterceptor.kt Github

copy

Full Screen

1package io.kotest.engine.spec.interceptor2import io.kotest.common.flatMap3import io.kotest.core.NamedTag4import io.kotest.core.annotation.RequiresTag5import io.kotest.core.annotation.requirestag.wrapper6import io.kotest.core.config.ProjectConfiguration7import io.kotest.core.config.ExtensionRegistry8import io.kotest.core.filter.SpecFilter9import io.kotest.core.spec.SpecRef10import io.kotest.core.test.TestCase11import io.kotest.core.test.TestResult12import io.kotest.engine.listener.TestEngineListener13import io.kotest.engine.spec.SpecExtensions14import io.kotest.engine.tags.isActive15import io.kotest.engine.tags.parse16import io.kotest.engine.tags.runtimeTags17import io.kotest.mpp.annotation18/​**19 * A [SpecFilter] which will ignore specs if they are annotated with @[RequiresTag]20 * and those tags are not present in the runtime tags.21 */​22internal class RequiresTagSpecInterceptor(23 private val listener: TestEngineListener,24 private val configuration: ProjectConfiguration,25 private val registry: ExtensionRegistry,26) : SpecRefInterceptor {27 override suspend fun intercept(28 ref: SpecRef,29 fn: suspend (SpecRef) -> Result<Map<TestCase, TestResult>>30 ): Result<Map<TestCase, TestResult>> {31 return when (val annotation = ref.kclass.annotation<RequiresTag>()) {32 null -> fn(ref)33 else -> {34 val requiredTags = annotation.wrapper.map { NamedTag(it) }.toSet()35 val expr = configuration.runtimeTags().parse()36 if (requiredTags.isEmpty() || expr.isActive(requiredTags)) {37 fn(ref)38 } else {39 runCatching { listener.specIgnored(ref.kclass, "Disabled by @RequiresTag") }40 .flatMap { SpecExtensions(registry).ignored(ref.kclass, "Disabled by @RequiresTag") }41 .map { emptyMap() }42 }43 }44 }45 }46}...

Full Screen

Full Screen

enabled.kt

Source: enabled.kt Github

copy

Full Screen

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}...

Full Screen

Full Screen

TagsExcludedDiscoveryExtension.kt

Source: TagsExcludedDiscoveryExtension.kt Github

copy

Full Screen

1package io.kotest.engine.spec.interceptor2import io.kotest.common.flatMap3import io.kotest.core.TagExpression4import io.kotest.core.config.ProjectConfiguration5import io.kotest.core.spec.Spec6import io.kotest.core.spec.SpecRef7import io.kotest.core.test.TestCase8import io.kotest.core.test.TestResult9import io.kotest.engine.listener.TestEngineListener10import io.kotest.engine.spec.SpecExtensions11import io.kotest.engine.tags.isPotentiallyActive12import io.kotest.engine.tags.parse13import io.kotest.engine.tags.runtimeTags14/​**15 * Filters any [Spec] that can be eagerly excluded based on the @[TagExpression] annotation at the class level.16 */​17class TagsExcludedSpecInterceptor(18 private val listener: TestEngineListener,19 private val conf: ProjectConfiguration,20) : SpecRefInterceptor {21 private val extensions = SpecExtensions(conf.registry)22 override suspend fun intercept(23 ref: SpecRef,24 fn: suspend (SpecRef) -> Result<Map<TestCase, TestResult>>25 ): Result<Map<TestCase, TestResult>> {26 val potentiallyActive = conf.runtimeTags().parse().isPotentiallyActive(ref.kclass)27 return if (potentiallyActive) {28 fn(ref)29 } else {30 runCatching { listener.specIgnored(ref.kclass, null) }31 .flatMap { extensions.ignored(ref.kclass, "Skipped by tags") }32 .map { emptyMap() }33 }34 }35}...

Full Screen

Full Screen

runtime.kt

Source: runtime.kt Github

copy

Full Screen

1package io.kotest.engine.tags2import io.kotest.core.Tag3import io.kotest.core.TagExpression4import io.kotest.core.config.ProjectConfiguration5import io.kotest.core.extensions.TagExtension6/​**7 * Returns runtime active [Tag]'s by invoking all registered [TagExtension]s and combining8 * any returned tags into a [TagExpression] container.9 */​10fun ProjectConfiguration.runtimeTags(): TagExpression {11 val extensions = this.registry.all().filterIsInstance<TagExtension>()12 return if (extensions.isEmpty()) TagExpression.Empty else extensions.map { it.tags() }.reduce { a, b -> a.combine(b) }13}...

Full Screen

Full Screen

ProjectConfiguration.runtimeTags

Using AI Code Generation

copy

Full Screen

1val runtimeTags = ProjectConfiguration.runtimeTags()2val runtimeTags = ProjectConfiguration.runtimeTags()3val runtimeTags = ProjectConfiguration.runtimeTags()4val runtimeTags = ProjectConfiguration.runtimeTags()5val runtimeTags = ProjectConfiguration.runtimeTags()6val runtimeTags = ProjectConfiguration.runtimeTags()7val runtimeTags = ProjectConfiguration.runtimeTags()8val runtimeTags = ProjectConfiguration.runtimeTags()9val runtimeTags = ProjectConfiguration.runtimeTags()10val runtimeTags = ProjectConfiguration.runtimeTags()11val runtimeTags = ProjectConfiguration.runtimeTags()12val runtimeTags = ProjectConfiguration.runtimeTags()13val runtimeTags = ProjectConfiguration.runtimeTags()14val runtimeTags = ProjectConfiguration.runtimeTags()15val runtimeTags = ProjectConfiguration.runtimeTags()

Full Screen

Full Screen

ProjectConfiguration.runtimeTags

Using AI Code Generation

copy

Full Screen

1val tags = ProjectConfiguration.runtimeTags()2val tags = ProjectConfiguration.runtimeTags()3val tags = ProjectConfiguration.runtimeTags()4val tags = ProjectConfiguration.runtimeTags()5val tags = ProjectConfiguration.runtimeTags()6val tags = ProjectConfiguration.runtimeTags()7val tags = ProjectConfiguration.runtimeTags()8val tags = ProjectConfiguration.runtimeTags()9val tags = ProjectConfiguration.runtimeTags()10val tags = ProjectConfiguration.runtimeTags()11val tags = ProjectConfiguration.runtimeTags()12val tags = ProjectConfiguration.runtimeTags()13val tags = ProjectConfiguration.runtimeTags()14val tags = ProjectConfiguration.runtimeTags()15val tags = ProjectConfiguration.runtimeTags()

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Are Agile Self-Managing Teams Realistic with Layered Management?

Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

An Interactive Guide To CSS Hover Effects

Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

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 runtime

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful