How to use ExecSpekTests class of org.spekframework.spek2.gradle.task package

Best Spek code snippet using org.spekframework.spek2.gradle.task.ExecSpekTests

MultiplatformPlugin.kt

Source:MultiplatformPlugin.kt Github

copy

Full Screen

...10import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget11import org.spekframework.spek2.gradle.domain.MultiplatformExtension12import org.spekframework.spek2.gradle.domain.SpekTest13import org.spekframework.spek2.gradle.kotlin.CompilerPlugin14import org.spekframework.spek2.gradle.task.ExecSpekTests15class MultiplatformPlugin : Plugin<Project> {16 override fun apply(project: Project) {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 }...

Full Screen

Full Screen

ExecSpekTests.kt

Source:ExecSpekTests.kt Github

copy

Full Screen

...3import org.gradle.api.tasks.Input4import org.gradle.api.tasks.TaskAction5import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation6import org.jetbrains.kotlin.gradle.plugin.KotlinTarget7open class ExecSpekTests: DefaultTask() {8 @Input9 val target = project.objects.property(KotlinTarget::class.java)10 @Input11 val compilation = project.objects.property(KotlinCompilation::class.java)12 @TaskAction13 fun run() {14 // do nothing15 }16}...

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