Best Kotest code snippet using io.kotest.assertions.print.platformPrint.javaIoFileKlass
platformPrint.kt
Source:platformPrint.kt
...17 */18@Suppress("UNCHECKED_CAST")19actual fun <A : Any> platformPrint(a: A): Print<A>? = when {20 javaNioPathKlass()?.isInstance(a) ?: false -> PathPrint as Print<A>21 javaIoFileKlass()?.isInstance(a) ?: false -> FilePrint as Print<A>22 else -> null23}24private fun javaNioPathKlass(): KClass<*>? = try {25 /*26 * There is no KClass reflection API to find a27 * class by string so the Java Class Reflection28 * API must be used.29 * See https://youtrack.jetbrains.com/issue/KT-1044030 */31 Class.forName("java.nio.file.Path").kotlin32} catch (_: ClassNotFoundException) {33 // ignore Path as it may not exist on Android.34 null35}36private fun javaIoFileKlass(): KClass<*>? = try {37 /*38 * There is no KClass reflection API to find a39 * class by string so the Java Class Reflection40 * API must be used.41 * See https://youtrack.jetbrains.com/issue/KT-1044042 */43 Class.forName("java.io.File").kotlin44} catch (_: ClassNotFoundException) {45 null46}...
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!!