Best Kotest code snippet using io.kotest.framework.multiplatform.native.specs.IrClass.isSpecClass
specs.kt
Source:specs.kt
1package io.kotest.framework.multiplatform.native2import org.jetbrains.kotlin.ir.declarations.IrClass3import org.jetbrains.kotlin.ir.declarations.IrFile4import org.jetbrains.kotlin.ir.types.IrType5import org.jetbrains.kotlin.ir.types.classFqName6import org.jetbrains.kotlin.ir.types.getClass7val specClasses = listOf(8 "io.kotest.core.spec.style.BehaviorSpec",9 "io.kotest.core.spec.style.DescribeSpec",10 "io.kotest.core.spec.style.ExpectSpec",11 "io.kotest.core.spec.style.FeatureSpec",12 "io.kotest.core.spec.style.FreeSpec",13 "io.kotest.core.spec.style.FunSpec",14 "io.kotest.core.spec.style.ShouldSpec",15 "io.kotest.core.spec.style.StringSpec",16 "io.kotest.core.spec.style.WordSpec",17)18/**19 * Returns any specs declared at the top level in this file.20 */21fun IrFile.specs() = declarations.filterIsInstance<IrClass>().filter { it.isSpecClass() }22/**23 * Recursively returns all supertypes for an [IrClass] to the top of the type tree.24 */25fun IrClass.superTypes(): List<IrType> =26 this.superTypes + this.superTypes.flatMap { it.getClass()?.superTypes() ?: emptyList() }27/**28 * Returns true if any of the parents of this class are a spec class.29 */30fun IrClass.isSpecClass() =31 superTypes().mapNotNull { it.classFqName?.asString() }.intersect(specClasses).isNotEmpty()...
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!!