How to use withConfiguration method of io.kotest.engine.TestEngineLauncher class

Best Kotest code snippet using io.kotest.engine.TestEngineLauncher.withConfiguration

TestEngineLauncher.kt

Source:TestEngineLauncher.kt Github

copy

Full Screen

...114 }115 /**116 * Returns a copy of this launcher with the given [extensions] added to the configuration.117 *118 * Note: If after invoking this method, the [withConfiguration] is invoked, then any changes119 * here will be lost.120 */121 fun withExtensions(vararg extensions: Extension): TestEngineLauncher = withExtensions(extensions.toList())122 /**123 * Returns a copy of this launcher with the given [extensions] added to the configuration.124 *125 * Note: If after invoking this method, the [withConfiguration] is invoked, then any changes126 * here will be lost.127 */128 fun withExtensions(extensions: List<Extension>): TestEngineLauncher {129 extensions.forEach { projectConfiguration.registry.add(it) }130 return this131 }132 fun withConfiguration(configuration: ProjectConfiguration): TestEngineLauncher {133 return TestEngineLauncher(134 listener = listener,135 projectConfiguration = configuration,136 configs = configs,137 refs = refs,138 tagExpression = tagExpression,139 )140 }141 fun toConfig(): TestEngineConfig {142 // if the engine was configured with explicit tags, we register those via a tag extension143 tagExpression?.let { projectConfiguration.registry.add(SpecifiedTagsTagExtension(it)) }144 return TestEngineConfig(145 listener = ThreadSafeTestEngineListener(146 PinnedSpecTestEngineListener(...

Full Screen

Full Screen

SystemPropertyFiltersTests.kt

Source:SystemPropertyFiltersTests.kt Github

copy

Full Screen

...46 mapOf(47 KotestEngineProperties.filterSpecs to "",48 KotestEngineProperties.filterTests to ""49 )50 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }51 numberOfTestsRunShouldBe(13)52 }53 test("filters a specific class") {54 withSystemProperties(55 mapOf(56 KotestEngineProperties.filterSpecs to "*DistantFutureSciFiTests",57 KotestEngineProperties.filterTests to ""58 )59 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }60 numberOfTestsRunShouldBe(7)61 }62 test("filters a class prefix") {63 withSystemProperties(64 mapOf(65 KotestEngineProperties.filterSpecs to "*FutureSciFiTests",66 KotestEngineProperties.filterTests to ""67 )68 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }69 numberOfTestsRunShouldBe(9)70 }71 test("filters a specific class and test") {72 withSystemProperties(73 mapOf(74 KotestEngineProperties.filterSpecs to "*NearFutureSciFiTests",75 KotestEngineProperties.filterTests to "Daedalus*"76 )77 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }78 numberOfTestsRunShouldBe(1)79 }80 test("filters a test name with spaces") {81 withSystemProperties(82 mapOf(83 KotestEngineProperties.filterSpecs to "",84 KotestEngineProperties.filterTests to "trek tests*"85 )86 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }87 numberOfTestsRunShouldBe(3)88 }89 test("filters all classes in a package") {90 withSystemProperties(91 mapOf(92 KotestEngineProperties.filterSpecs to "com.sksamuel.kotest.engine.interceptors.filters1.*",93 KotestEngineProperties.filterTests to ""94 )95 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }96 numberOfTestsRunShouldBe(2)97 }98 test("filters nested tests in a context") {99 withSystemProperties(100 mapOf(101 KotestEngineProperties.filterSpecs to "",102 KotestEngineProperties.filterTests to "expanse tests*"103 )104 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }105 numberOfTestsRunShouldBe(4)106 }107 test("filter tests using prefix and suffix wildcard") {108 withSystemProperties(109 mapOf(110 KotestEngineProperties.filterSpecs to "",111 KotestEngineProperties.filterTests to "*anse tes*"112 )113 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }114 numberOfTestsRunShouldBe(4)115 }116 test("filter tests with prefix wildcard") {117 withSystemProperties(118 mapOf(119 KotestEngineProperties.filterSpecs to "",120 KotestEngineProperties.filterTests to "*BC-304"121 )122 ) { TestEngineLauncher().withClasses(testSuite).withConfiguration(ProjectConfiguration()).launch() }123 numberOfTestsRunShouldBe(2)124 testsRunShouldBe("Daedalus BC-304", "Odyssey BC-304")125 }126})127private class DistantFutureSciFiTests : FunSpec({128 context("trek tests") {129 test("Enterprise NCC-1701") { testAndIncrementCounter() }130 test("Excelsior NCC-2000") { testAndIncrementCounter() }131 test("Defiant NX-74205") { testAndIncrementCounter() }132 }133 context("expanse tests") {134 test("MCRN Donnager") { testAndIncrementCounter() }135 test("Rocinante") { testAndIncrementCounter() }136 test("UNN Arboghast") { testAndIncrementCounter() }...

Full Screen

Full Screen

BeforeSpecListenerTest.kt

Source:BeforeSpecListenerTest.kt Github

copy

Full Screen

...22 counter.set(0)23 val listener = CollectingTestEngineListener()24 TestEngineLauncher(listener)25 .withClasses(MyPopulatedSpec3::class)26 .withConfiguration(c)27 .launch()28 listener.specs.size shouldBe 129 listener.tests.size shouldBe 130 counter.get() shouldBe 531 }32 test("BeforeSpecExtension's should be triggered for a spec without tests") {33 val c = ProjectConfiguration()34 c.registry.add(MyBeforeSpecListener)35 counter.set(0)36 TestEngineLauncher(NoopTestEngineListener)37 .withClasses(BeforeSpecErrorNoTests::class)38 .withConfiguration(c)39 .launch()40 counter.get() shouldBe 141 }42 test("BeforeSpecListener's exceptions should be propagated to specExit") {43 val listener = CollectingTestEngineListener()44 TestEngineLauncher(listener)45 .withClasses(MyErrorSpec3::class)46 .launch()47 listener.specs.size shouldBe 148 listener.specs[MyErrorSpec3::class]!!.errorOrNull.shouldBeInstanceOf<ExtensionException.BeforeSpecException>()49 listener.tests.size shouldBe 050 }51 }52}...

Full Screen

Full Screen

SpecExtensionTest.kt

Source:SpecExtensionTest.kt Github

copy

Full Screen

...23 val conf = io.kotest.core.config.ProjectConfiguration()24 conf.registry.add(ext)25 TestEngineLauncher(NoopTestEngineListener)26 .withClasses(SpecInterceptSingleInstance::class)27 .withConfiguration(conf)28 .launch()29 count shouldBe 130 }31 test("SpecExtension should be invoked for each instance created") {32 var count = 033 val ext = object : SpecExtension {34 override suspend fun intercept(spec: Spec, execute: suspend (Spec) -> Unit) {35 execute(spec)36 count++37 }38 }39 val conf = io.kotest.core.config.ProjectConfiguration()40 conf.registry.add(ext)41 TestEngineLauncher(NoopTestEngineListener)42 .withClasses(SpecInterceptInstancePerTest::class)43 .withConfiguration(conf)44 .launch()45 count shouldBe 346 }47 test("SpecExtension can opt to skip processing") {48 val ext = object : SpecExtension {49 override suspend fun intercept(spec: Spec, execute: suspend (Spec) -> Unit) {}50 }51 val conf = io.kotest.core.config.ProjectConfiguration()52 conf.registry.add(ext)53 val collecting = CollectingTestEngineListener()54 TestEngineLauncher(collecting)55 .withClasses(SpecInterceptInstancePerTest::class)56 .withConfiguration(conf)57 .launch()58 collecting.tests.shouldBeEmpty()59 }60 }61}62private class SpecInterceptSingleInstance : FunSpec() {63 init {64 isolationMode = IsolationMode.SingleInstance65 test("a") {}66 test("b") {}67 }68}69private class SpecInterceptInstancePerTest : FunSpec() {70 init {...

Full Screen

Full Screen

AfterProjectListenerExceptionTest.kt

Source:AfterProjectListenerExceptionTest.kt Github

copy

Full Screen

...27 val c = ProjectConfiguration()28 c.registry.add(projectListener)29 TestEngineLauncher(listener)30 .withClasses(DummySpec7::class)31 .withConfiguration(c)32 .launch()33 errors shouldHaveSize 134 errors[0].shouldBeInstanceOf<ExtensionException.AfterProjectException>()35 errors[0].cause!! shouldHaveMessage "ARRGH"36 }37 test("multiple afterProject exceptions should be collected") {38 val projectListener1 = object : ProjectListener {39 override suspend fun afterProject() {40 error("GLIPP")41 }42 }43 val projectListener2 = object : ProjectListener {44 override suspend fun afterProject() {45 error("WHACK")46 }47 }48 val errors: MutableList<Throwable> = mutableListOf()49 val listener = object : AbstractTestEngineListener() {50 override suspend fun engineFinished(t: List<Throwable>) {51 errors.addAll(t)52 }53 }54 val c = ProjectConfiguration()55 c.registry.add(projectListener1)56 c.registry.add(projectListener2)57 TestEngineLauncher(listener)58 .withClasses(DummySpec7::class)59 .withConfiguration(c)60 .launch()61 errors shouldHaveSize 262 errors.filterIsInstance<ExtensionException.AfterProjectException>() shouldHaveSize 263 errors.forOne {64 it.cause!!.shouldHaveMessage("GLIPP")65 }66 errors.forOne {67 it.cause!!.shouldHaveMessage("WHACK")68 }69 }70})71private class DummySpec7 : FunSpec({72 test("foo") {}73})...

Full Screen

Full Screen

SpecInstantiationListenerTest.kt

Source:SpecInstantiationListenerTest.kt Github

copy

Full Screen

...24 val c = ProjectConfiguration()25 c.registry.add(ext)26 TestEngineLauncher(NoopTestEngineListener)27 .withClasses(SpecInstantiationSuccessSpec::class)28 .withConfiguration(c)29 .launch()30 fired shouldBe true31 }32 test("SpecInstantiationListener.specInstantiationError should be notified on failure") {33 var fired = false34 val ext = object : SpecInstantiationListener {35 override fun specInstantiated(spec: Spec) {36 error("boom")37 }38 override fun specInstantiationError(kclass: KClass<out Spec>, t: Throwable) {39 fired = true40 }41 }42 val c = ProjectConfiguration()43 c.registry.add(ext)44 TestEngineLauncher(NoopTestEngineListener)45 .withClasses(SpecInstantiationFailureSpec::class)46 .withConfiguration(c)47 .launch()48 fired shouldBe true49 }50 }51}52private class SpecInstantiationSuccessSpec : FunSpec() {53 init {54 test("a") {}55 }56}57private class SpecInstantiationFailureSpec : FunSpec() {58 init {59 error("zapp!")60 }...

Full Screen

Full Screen

BeforeProjectListenerTest.kt

Source:BeforeProjectListenerTest.kt Github

copy

Full Screen

...16 }17 })18 TestEngineLauncher(NoopTestEngineListener)19 .withClasses(DummySpec5::class)20 .withConfiguration(c)21 .launch()22 fired shouldBe true23 }24 test("BeforeProjectListener's beforeProject method should be fired") {25 var fired = false26 val c = ProjectConfiguration()27 c.registry.add(object : BeforeProjectListener {28 override suspend fun beforeProject() {29 fired = true30 }31 })32 TestEngineLauncher(NoopTestEngineListener)33 .withClasses(DummySpec5::class)34 .withConfiguration(c)35 .launch()36 fired shouldBe true37 }38})39private class DummySpec5 : FunSpec({40 test("foo") {}41})...

Full Screen

Full Screen

AfterProjectListenerTest.kt

Source:AfterProjectListenerTest.kt Github

copy

Full Screen

...16 }17 })18 TestEngineLauncher(NoopTestEngineListener)19 .withClasses(DummySpec4::class)20 .withConfiguration(c)21 .launch()22 fired shouldBe true23 }24 test("AfterProjectListener's afterProject method should be fired") {25 var fired = false26 val c = ProjectConfiguration()27 c.registry.add(object : AfterProjectListener {28 override suspend fun afterProject() {29 fired = true30 }31 })32 TestEngineLauncher(NoopTestEngineListener)33 .withClasses(DummySpec4::class)34 .withConfiguration(c)35 .launch()36 fired shouldBe true37 }38})39private class DummySpec4 : FunSpec({40 test("foo") {}41})...

Full Screen

Full Screen

withConfiguration

Using AI Code Generation

copy

Full Screen

1val launcher = TestEngineLauncher() launcher . withConfiguration ( configuration ) launcher . withSpecs ( listOf ( MySpec :: class )) launcher . execute ()2val executor = SpecExecutor ( configuration ) executor . execute ( MySpec :: class )3val runner = SpecRunner ( configuration ) runner . execute ( MySpec :: class )4val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())5val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())6val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())7val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())8val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())9val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())10val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())11val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())12val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())13val runner = SpecRunner ( configuration ) runner . execute ( MySpec ())

Full Screen

Full Screen

withConfiguration

Using AI Code Generation

copy

Full Screen

1val config = ProjectConfig(extensions = listOf(ListenerExtension))2TestEngineLauncher( config ).withConfiguration( config ).launch()3TestEngineLauncher( ProjectConfig() ).withExtensions(ListenerExtension).launch()4class MySpec : FunSpec(), ListenerExtension by ListenerExtension.Delegate {5init {6}7}8class MySpec : FunSpec({9}, extensions = listOf(ListenerExtension))10class MySpec : StringSpec({11}, extensions = listOf(ListenerExtension))12class MySpec : WordSpec({13}, extensions = listOf(ListenerExtension))14class MySpec : BehaviorSpec({15}, extensions = listOf(ListenerExtension))16class MySpec : ExpectSpec({17}, extensions = listOf(ListenerExtension))18class MySpec : FeatureSpec({19}, extensions = listOf(ListenerExtension))20class MySpec : FreeSpec({21}, extensions = listOf(ListenerExtension))22class MySpec : ShouldSpec({23}, extensions = listOf(ListenerExtension))24class MySpec : DescribeSpec({25}, extensions = listOf(ListenerExtension))26@ExtendWith(ListenerExtension::class)27class MySpec : AnnotationSpec() {28}

Full Screen

Full Screen

withConfiguration

Using AI Code Generation

copy

Full Screen

1val launcher = TestEngineLauncher()2launcher.withConfiguration(3}4val configuration = Configuration()5configuration.withConfiguration(6}7class MySpec : FunSpec({8withConfiguration(9}10})11class MySpec : FunSpec({12withConfiguration(13}14})15class MySpec : FunSpec({16withConfiguration(17}18})19class MySpec : FunSpec({20withConfiguration(21}22})23class MySpec : FunSpec({24withConfiguration(25}26})27class MySpec : FunSpec({28withConfiguration(29}30})31class MySpec : FunSpec({32withConfiguration(33}34})35class MySpec : FunSpec({36withConfiguration(37}38})39class MySpec : FunSpec({40withConfiguration(41}42})43class MySpec : FunSpec({44withConfiguration(45}

Full Screen

Full Screen

withConfiguration

Using AI Code Generation

copy

Full Screen

1val launcher = TestEngineLauncher()2launcher.withConfiguration(3TestEngineConfiguration(4launcher.execute(5specs = listOf(6val launcher = TestEngineLauncher()7launcher.execute(8specs = listOf(

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 Kotest 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