How to use configureDefaults method of org.spekframework.spek2.gradle.entry.MultiplatformPlugin class

Best Spek code snippet using org.spekframework.spek2.gradle.entry.MultiplatformPlugin.configureDefaults

MultiplatformPlugin.kt

Source:MultiplatformPlugin.kt Github

copy

Full Screen

...17 project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {18 val kotlinMppExtension = checkNotNull(project.extensions.findByType(KotlinMultiplatformExtension::class.java)) { "Kotlin multiplatform plugin not applied!" }19 val mppExtension = project.extensions.create("spek2", MultiplatformExtension::class.java, project.objects)20 configureTestsContainer(project, mppExtension)21 configureDefaults(project, mppExtension, kotlinMppExtension)22 }23 project.pluginManager.apply(CompilerPlugin::class.java)24 }25 private fun configureTestsContainer(project: Project, mppExtension: MultiplatformExtension) {26 mppExtension.tests.all {27 val spekTest = this28 project.tasks.create("spek${spekTest.name.capitalize()}", ExecSpekTests::class.java) {29 group = SPEK_GROUP30 description = "Run Spek tests for ${spekTest.name}"31 target.set(spekTest.target)32 compilation.set(spekTest.target.map { it.compilations.getByName("test") })33 project.afterEvaluate {34 val target = spekTest.target.get()35 project.tasks.named("${target.name}SpekTests").configure {36 dependsOn(this@create)37 }38 when (val compilation = spekTest.compilation.orElse(target.compilations.named("test")).get()) {39 is KotlinNativeCompilation -> configureNativeTest(project, compilation, this@create, spekTest.name)40 is KotlinJvmCompilation -> {41 if (spekTest.useJUnitPlatform) {42 configureJvmJUnitPlatformTest(project, compilation, this@create, spekTest)43 } else {44 throw GradleException("First class jvm test runner not supported yet.")45 }46 }47 }48 }49 }50 }51 }52 private fun configureNativeTest(project: Project, compilation: KotlinNativeCompilation, spekTask: ExecSpekTests, testName: String) {53 compilation.target.binaries {54 executable("spek${testName.capitalize()}", listOf(DEBUG)) {55 this.compilation = compilation56 entryPoint = "org.spekframework.spek2.launcher.main"57 runTask?.let { runTask ->58 spekTask.dependsOn(runTask)59 }60 }61 }62 }63 private fun configureJvmJUnitPlatformTest(project: Project, compilation: KotlinJvmCompilation, spekTask: ExecSpekTests, test: SpekTest) {64 project.tasks.create("runSpek${test.name.capitalize()}", Test::class.java) {65 testClassesDirs = compilation.output.classesDirs66 classpath = compilation.compileDependencyFiles + compilation.runtimeDependencyFiles67 useJUnitPlatform(test.junitPlatformConfigure)68 useJUnitPlatform {69 includeEngines("spek2")70 }71 spekTask.dependsOn(this)72 }73 }74 private fun configureDefaults(project: Project, mppExtension: MultiplatformExtension, kotlinMppExtension: KotlinMultiplatformExtension) {75 if (!mppExtension.enabled) {76 return77 }78 val allSpekTestsTask = project.tasks.register("allSpekTests") {79 group = VERIFICATION_GROUP80 description = "Run all Spek tests."81 // prevents gradle from skipping this task82 onlyIf { true }83 doLast { }84 }85 kotlinMppExtension.targets.all {86 when (this) {87 is KotlinNativeTargetWithTests<*>, is KotlinJvmTarget -> {88 project.tasks.create("${this.name}SpekTests") {...

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 Spek automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful