How to use ConsoleLauncher class of org.spekframework.spek2.launcher package

Best Spek code snippet using org.spekframework.spek2.launcher.ConsoleLauncher

ConsoleLauncher.kt

Source:ConsoleLauncher.kt Github

copy

Full Screen

...56 hasFailure = true57 }58 }59}60abstract class AbstractConsoleLauncher {61 fun launch(context: DiscoveryContext, args: List<String>): Int {62 val parsedArgs = parseArgs(args)63 val listeners = createListenersFor(parsedArgs.reporterTypes)64 val runtime = SpekRuntime()65 val paths = mutableListOf<Path>()66 paths.addAll(parsedArgs.paths)67 // todo: empty paths implies run everything68 if (paths.isEmpty()) {69 paths.add(PathBuilder.ROOT)70 }71 val discoveryRequest = DiscoveryRequest(context, paths)72 val discoveryResult = runtime.discover(discoveryRequest)73 val listener = CompoundExecutionListener(listeners)74 val executionRequest = ExecutionRequest(discoveryResult.roots, listener)75 runtime.execute(executionRequest)76 return when {77 parsedArgs.reportExitCode && !listener.isSuccessful() -> -178 parsedArgs.reportExitCode && listener.isSuccessful() -> 079 else -> 080 }81 }82 private fun createListenersFor(reporterTypes: List<ReporterType>): List<ExecutionListener> {83 return reporterTypes.map { reporter ->84 when (reporter) {85 is ConsoleReporterType -> when (reporter.format) {86 ConsoleReporterType.Format.BASIC -> BasicConsoleReporter()87 else -> throw AssertionError("Unsupported console reporter: ${reporter.format}")88 }89 else -> throw AssertionError("Unsupported reporter: $reporter")90 }91 }92 }93 private fun parseArgs(args: List<String>): LauncherArgs {94 var rawReporterType: String? = null95 var rawConsoleReporterFormat: String? = null96 var reportExitCode = true97 args.forEach { arg ->98 when {99 arg.startsWith("--reporter=") -> {100 rawReporterType = arg.split("=")[1]101 }102 arg.startsWith("--console-reporter-format=") -> {103 rawConsoleReporterFormat = arg.split("=")[1]104 }105 arg == "--dont-report-exit-code" -> reportExitCode = false106 else -> throw AssertionError("Unsupported arg: $arg")107 }108 }109 val reporterType = rawReporterType?.let {110 when (it) {111 "console" -> {112 val format = if (rawConsoleReporterFormat != null) {113 when (rawConsoleReporterFormat) {114 "basic" -> ConsoleReporterType.Format.BASIC115 "sm" -> ConsoleReporterType.Format.SERVICE_MESSAGE116 else -> throw AssertionError("Unsupported console reporter format: $rawConsoleReporterFormat")117 }118 } else {119 ConsoleReporterType.Format.BASIC120 }121 ConsoleReporterType(format)122 }123 else -> throw AssertionError("Unsupported reporter: $rawReporterType")124 }125 } ?: ConsoleReporterType(ConsoleReporterType.Format.BASIC)126 return LauncherArgs(127 listOf(reporterType),128 emptyList(),129 reportExitCode130 )131 }132}133expect class ConsoleLauncher(): AbstractConsoleLauncher...

Full Screen

Full Screen

build.gradle.kts

Source:build.gradle.kts Github

copy

Full Screen

...67 dependsOn(testClasses)68 val reportsDir = file("$buildDir/test-results")69 outputs.dir(reportsDir)70 classpath = sourceSets.test.get().runtimeClasspath71 main = "org.junit.platform.console.ConsoleLauncher"72 args("--scan-classpath")73 args("--details", "tree")74 args("--reports-dir", reportsDir)75 }76 test {77 // useJUnitPlatform() ... https://github.com/gradle/gradle/issues/491278 dependsOn(consoleLauncherTest)79 exclude("**/*")80 }81}...

Full Screen

Full Screen

DefaultRunner.kt

Source:DefaultRunner.kt Github

copy

Full Screen

...10}11fun spekMain(args: Array<String>) {12 val discoveryContextBuilder = DiscoveryContext.builder()13 speks.forEach { discoveryContextBuilder.addTest(it.cls, it.factory) }14 val launcher = ConsoleLauncher()15 val exitCode = launcher.launch(discoveryContextBuilder.build(), args.toList())16 exitProcess(exitCode)17}...

Full Screen

Full Screen

impl.kt

Source:impl.kt Github

copy

Full Screen

1package org.spekframework.spek2.launcher2actual class ConsoleLauncher: AbstractConsoleLauncher()...

Full Screen

Full Screen

console.kt

Source:console.kt Github

copy

Full Screen

1package org.spekframework.spek2.launcher2actual class ConsoleLauncher: AbstractConsoleLauncher()...

Full Screen

Full Screen

ConsoleLauncher

Using AI Code Generation

copy

Full Screen

1import org.spekframework.spek2.launcher.ConsoleLauncher2import org.spekframework.spek2.runtime.SpekRuntime3import org.spekframework.spek2.runtime.execution.ExecutionListener4import org.spekframework.spek2.runtime.execution.ExecutionResult5import org.spekframework.spek2.runtime.execution.ExecutionResult.*6import org.spekframework.spek2.runtime.scope.Path7import org.spekframework.spek2.runtime.scope.PathBuilder8import org.spekframework.spek2.runtime.scope.TestScopeImpl9import org.spekframework.spek2.runtime.scope.TestStatus10import org.spekframework.spek2.runtime.scope.TestStatus.*11import org.spekframework.spek2.runtime.scope.toPath12import org.spekframework.spek2.launcher.ConsoleLauncher13import org.spekframework.spek2.runtime.SpekRuntime14import org.spekframework.spek2.runtime.execution.ExecutionListener15import org.spekframework.spek2.runtime.execution.ExecutionResult16import org.spekframework.spek2.runtime.execution.ExecutionResult.*17import org.spekframework.spek2.runtime.scope.Path18import org.spekframework.spek2.runtime.scope.PathBuilder19import org.spekframework.spek2.runtime.scope.TestScopeImpl20import org.spekframework.spek2.runtime.scope.TestStatus21import org.spekframework.spek2.runtime.scope.TestStatus.*22import org.spekframework.spek2.runtime.scope.toPath23import org.spekframework.spek2.launcher.ConsoleLauncher24import org.spekframework.spek2.runtime.SpekRuntime25import org.spekframework.spek2.runtime.execution.ExecutionListener26import org.spekframework.spek2.runtime.execution.ExecutionResult27import org.spekframework.spek2.runtime.execution.ExecutionResult.*28import org.spekframework.spek2.runtime.scope.Path29import org.spekframework.spek2.runtime.scope.PathBuilder30import org.spekframework.spek2.runtime.scope.TestScopeImpl31import org.spekframework.spek2.runtime.scope.TestStatus32import org.spekframework.spek2.runtime.scope.TestStatus.*33import org.spekframework.spek2.runtime.scope.toPath34import org.spekframework.spek2.launcher.ConsoleLauncher

Full Screen

Full Screen

ConsoleLauncher

Using AI Code Generation

copy

Full Screen

1import org.spekframework.spek2.launcher.SpeckLauncher2import org.spekframework.spek2.launcher.SpeckLauncher3import org.spekframework.spek2.launcher.SpeckLauncher4import org.spekframework.spek2.launcher.SpeckLauncher5import org.spekframework.spek2.launcher.SpeckLauncher6import org.spekframework.spek2.launcher.SpeckLauncher7import org.spekframework.spek2.launcher.SpeckLauncher

Full Screen

Full Screen

ConsoleLauncher

Using AI Code Generation

copy

Full Screen

1import org.spekframework.spek2.launcher.*2ConsoleLauncher.main(arrayOf("org.spekframework.spek2.junit.SpekTestEngine", "org.spekframework.spek2.runtime.scope.Path"))3import org.spekframework.spek2.launcher.*4ConsoleLauncher.main(arrayOf("org.spekframework.spek2.junit.SpekTestEngine", "org.spekframework.spek2.runtime.scope.Path"))5import org.spekframework.spek2.launcher.*6ConsoleLauncher.main(arrayOf("org.spekframework.spek2.junit.SpekTestEngine", "org.spekframework.spek2.runtime.scope.Path"))7import org.spekframework.spek2.launcher.*8ConsoleLauncher.main(arrayOf("org.spekframework.spek2.junit.SpekTestEngine", "org.spekframework.spek2.runtime.scope.Path"))

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