How to use containAll class of io.kotest.matchers.collections package

Best Kotest code snippet using io.kotest.matchers.collections.containAll

AbstractDependencyNavigatorTest.kt

Source:AbstractDependencyNavigatorTest.kt Github

copy

Full Screen

...19package org.ossreviewtoolkit.model20import io.kotest.core.spec.style.WordSpec21import io.kotest.matchers.collections.beEmpty22import io.kotest.matchers.collections.contain23import io.kotest.matchers.collections.containAll24import io.kotest.matchers.collections.containExactly25import io.kotest.matchers.collections.containExactlyInAnyOrder26import io.kotest.matchers.collections.haveSize27import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder28import io.kotest.matchers.maps.containExactly as containExactlyEntries29import io.kotest.matchers.sequences.beEmpty as beEmptySequence30import io.kotest.matchers.sequences.containExactly as containSequenceExactly31import io.kotest.matchers.should32import io.kotest.matchers.shouldBe33import io.kotest.matchers.shouldNot34import io.kotest.matchers.shouldNotBe35import java.io.File36import java.time.Instant37import org.ossreviewtoolkit.utils.test.readOrtResult38import org.ossreviewtoolkit.utils.test.shouldNotBeNull39/**40 * A base class for tests of concrete [DependencyNavigator] implementations.41 *42 * The class is configured with an ORT result file that contains the expected results in a specific format. It then43 * runs tests on the [DependencyNavigator] of this result and checks whether it returns the correct dependency44 * information.45 */46abstract class AbstractDependencyNavigatorTest : WordSpec() {47 /** The name of the result file to be used by all test cases. */48 protected abstract val resultFileName: String49 /**50 * The name of the file with a result that contains issues. This is used by tests of the collectIssues() function.51 */52 protected abstract val resultWithIssuesFileName: String53 private val testResult by lazy { readOrtResult(resultFileName) }54 private val testProject by lazy { testResult.getProject(PROJECT_ID)!! }55 protected val navigator by lazy { testResult.dependencyNavigator }56 init {57 "scopeNames" should {58 "return the scope names of a project" {59 navigator.scopeNames(testProject) should containExactlyInAnyOrder("compile", "test")60 }61 }62 "directDependencies" should {63 "return the direct dependencies of a project" {64 navigator.directDependencies(testProject, "test").map { it.id } should containSequenceExactly(65 Identifier("Maven:org.scalacheck:scalacheck_2.12:1.13.5"),66 Identifier("Maven:org.scalatest:scalatest_2.12:3.0.4")67 )68 }69 "return an empty sequence for an unknown scope" {70 navigator.directDependencies(testProject, "unknownScope") should beEmptySequence()71 }72 }73 "scopeDependencies" should {74 "return a map with scopes and their dependencies for a project" {75 val scopeDependencies = navigator.scopeDependencies(testProject)76 scopeDependencies.keys should containExactlyInAnyOrder("compile", "test")77 scopeDependencies["compile"] shouldNotBeNull {78 this should haveSize(17)79 this should containAll(80 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),81 Identifier("Maven:org.scala-lang:scala-reflect:2.12.2"),82 Identifier("Maven:org.scala-lang:scala-library:2.12.3")83 )84 }85 scopeDependencies["test"] shouldNotBeNull {86 this should haveSize(6)87 this should containAll(88 Identifier("Maven:org.scalacheck:scalacheck_2.12:1.13.5"),89 Identifier("Maven:org.scalactic:scalactic_2.12:3.0.4")90 )91 }92 }93 "return a map with scopes and their direct dependencies by using maxDepth = 1" {94 val scopeDependencies = navigator.scopeDependencies(testProject, maxDepth = 1)95 scopeDependencies["compile"] shouldNotBeNull {96 this should haveSize(7)97 this shouldNot contain(Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"))98 }99 }100 "return a map with scopes and their dependencies up to a given maxDepth" {101 val scopeDependencies = navigator.scopeDependencies(testProject, maxDepth = 2)102 scopeDependencies["compile"] shouldNotBeNull {103 this should haveSize(14)104 this shouldNot contain(105 Identifier("Maven:org.scala-lang.modules:scala-java8-compat_2.12:0.8.0")106 )107 }108 }109 "return a map with scopes and their dependencies with filter criteria" {110 val matchedIds = mutableSetOf<Identifier>()111 val scopeDependencies = navigator.scopeDependencies(testProject) { node ->112 matchedIds += node.id113 node.id.namespace == "com.typesafe.akka"114 }115 scopeDependencies["compile"] shouldNotBeNull {116 this should containExactlyInAnyOrder(117 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),118 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")119 )120 }121 matchedIds should haveSize(23)122 }123 }124 "dependenciesForScope" should {125 "return an empty set for an unknown scope" {126 navigator.dependenciesForScope(testProject, "unknownScope") should beEmpty()127 }128 "return the dependencies of a specific scope" {129 val compileDependencies = navigator.dependenciesForScope(testProject, "compile")130 compileDependencies should haveSize(17)131 compileDependencies should containAll(132 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),133 Identifier("Maven:org.scala-lang:scala-reflect:2.12.2"),134 Identifier("Maven:org.scala-lang:scala-library:2.12.3")135 )136 }137 "return the dependencies of a specific scope up to a given maxDepth" {138 val compileDependencies = navigator.dependenciesForScope(testProject, "compile", maxDepth = 2)139 compileDependencies should haveSize(14)140 compileDependencies shouldNot contain(141 Identifier("Maven:org.scala-lang.modules:scala-java8-compat_2.12:0.8.0")142 )143 }144 "return the dependencies of a specific scope with filter criteria" {145 val akkaDependencies = navigator.dependenciesForScope(testProject, "compile") { node ->...

Full Screen

Full Screen

RunRobotConfigurationTest.kt

Source:RunRobotConfigurationTest.kt Github

copy

Full Screen

...4import de.qualersoft.robotframework.gradleplugin.extensions.RobotFrameworkExtension5import de.qualersoft.robotframework.gradleplugin.robotframework6import io.kotest.matchers.collections.beEmpty7import io.kotest.matchers.collections.contain8import io.kotest.matchers.collections.containAll9import io.kotest.matchers.collections.containsInOrder10import io.kotest.matchers.collections.haveSize11import io.kotest.matchers.should12import io.kotest.matchers.shouldNot13import org.gradle.api.Project14import org.gradle.testfixtures.ProjectBuilder15import org.junit.jupiter.api.Test16import org.junit.jupiter.api.assertAll17import java.io.File18import java.nio.file.Paths1920internal class RunRobotConfigurationTest : ConfigurationTestBase() {2122 private val project: Project = ProjectBuilder.builder().build().also {23 it.pluginManager.apply(PLUGIN_ID)24 }2526 private val rf: RobotFrameworkExtension = project.robotframework()2728 @Test29 fun settingTheSuiteStatLevelOfBotRobotConfiguration() {30 val result = applyConfig {31 it.suiteStatLevel.set(5)32 }.generateArguments().toList()3334 assertAll(35 { result should containsInOrder(listOf("--suitestatlevel", "5")) }36 )37 }3839 @Test40 fun `generate default run arguments`() {41 val result = applyConfig { }.generateArguments().toList()42 val expected = createDefaultsWithoutExtensionParam() + listOf("-F", "robot")43 assertAll(44 { result should haveSize(expected.size) },45 { result should containAll(expected) }46 )47 }4849 @Test50 fun `add an extension to default should override default entry`() {51 val result = applyConfig {52 it.extension.add("newRobot")53 }.generateArguments().toList()54 val expected = createDefaultsWithoutExtensionParam() + listOf("-F", "newRobot")55 assertAll(56 { result should haveSize(expected.size) },57 { result should containAll(expected) },58 { result shouldNot contain("robot") }59 )60 }6162 @Test63 fun `add two extensions should result in two entries`() {64 val result = applyConfig {65 it.extension.add("newRobot1")66 it.extension.add("newRobot2")67 }.generateArguments().toList()68 val expected = createDefaultsWithoutExtensionParam() + listOf("-F", "newRobot1", "-F", "newRobot2")69 assertAll(70 { result should haveSize(expected.size) },71 { result should containAll(expected) },72 { result shouldNot contain("robot") }73 )74 }7576 @Test77 fun `empty the extension should also remove default`() {78 val result = applyConfig {79 it.extension.empty()80 }.generateArguments().toList()81 val expected = createDefaultsWithoutExtensionParam()82 assertAll(83 { result should haveSize(expected.size) },84 { result should containAll(expected) },85 { result shouldNot contain("robot") }86 )87 }8889 @Test90 fun addSingleVariable() {91 val result = applyConfig {92 it.variables.put("MyVar", "42")93 }.generateArguments().toList()9495 assertAll(96 { result shouldNot beEmpty() },97 { result should containsInOrder(listOf("-v", "MyVar:42")) }98 )99 }100101 @Test102 fun addMultibleVariables() {103 val result = applyConfig {104 it.variables.putAll(mapOf("MyVar1" to "42", "MyVar2" to "0815"))105 }.generateArguments().toList()106107 assertAll(108 { result shouldNot beEmpty() },109 { result should containsInOrder(listOf("-v", "MyVar1:42")) },110 { result should containsInOrder(listOf("-v", "MyVar2:0815")) }111 )112 }113114 @Test115 fun addVariableFiles() {116 val result = applyConfig {117 it.variableFiles.add("./settings.property")118 }.generateArguments().toList()119 val expected = createDefaults() + listOf("-V", "./settings.property")120 assertAll(121 { result should haveSize(expected.size) },122 { result should containAll(expected) }123 )124 }125126 @Test127 fun addDebugFile() {128 val file = if (System.getProperty("os.name").contains("wind", true)) {129 File("C:\\temp")130 } else {131 File("/temp")132 }133134 val result = applyConfig {135 it.debugFile.fileValue(file)136 }.generateArguments().toList()137 val expected = createDefaults() + listOf("-b", file.absolutePath)138 assertAll(139 { result should haveSize(expected.size) },140 { result should containAll(expected) }141 )142 }143144 @Test145 fun `set maxerrorlines to negative will generate NONE entry`() {146 val result = applyConfig {147 it.maxErrorLines.set(-1)148 }.generateArguments().toList()149 val expected = listOf(150 "-d", Paths.get(project.buildDir.absolutePath, "reports", "robotframework").toFile().absolutePath,151 "-l", "log.html", "-r", "report.html", "-x", "robot-xunit-results.xml", "-F", "robot",152 "--randomize", "none", "--console", "verbose", "-W", "78", "-K", "auto", "--maxerrorlines", "none"153 )154 assertAll(155 { result should haveSize(expected.size) },156 { result should containAll(expected) },157 { result shouldNot contain("40") }158 )159 }160161 @Test162 fun addListener() {163 val result = applyConfig {164 it.listener.add("aListener")165 }.generateArguments().toList()166 val expected = createDefaults() + listOf("--listener", "aListener")167 assertAll(168 { result should haveSize(expected.size) },169 { result should containAll(expected) }170 )171 }172173 @Test174 fun enableDryrunMode() {175 val result = applyConfig {176 it.dryrun.set(true)177 }.generateArguments().toList()178 val expected = createDefaults() + listOf("--dryrun")179 assertAll(180 { result should haveSize(expected.size) },181 { result should containAll(expected) }182 )183 }184185 @Test186 fun enableExitOnFailureMode() {187 val result = applyConfig {188 it.exitOnFailure.set(true)189 }.generateArguments().toList()190 val expected = createDefaults() + listOf("-X")191 assertAll(192 { result should haveSize(expected.size) },193 { result should containAll(expected) }194 )195 }196197 @Test198 fun enableExitOnErrorMode() {199 val result = applyConfig {200 it.exitOnError.set(true)201 }.generateArguments().toList()202 val expected = createDefaults() + listOf("--exitonerror")203 assertAll(204 { result should haveSize(expected.size) },205 { result should containAll(expected) }206 )207 }208209 @Test210 fun enableSkipTearDownOnExitMode() {211 val result = applyConfig {212 it.skipTearDownOnExit.set(true)213 }.generateArguments().toList()214 val expected = createDefaults() + listOf("--skipteardownonexit")215 assertAll(216 { result should haveSize(expected.size) },217 { result should containAll(expected) }218 )219 }220221 @Test222 fun changeRandomizeMode() {223 val result = applyConfig {224 it.randomize.set("tests:1234")225 }.generateArguments().toList()226 val expected = listOf(227 "-d", Paths.get(project.buildDir.absolutePath, "reports", "robotframework").toFile().absolutePath,228 "-l", "log.html", "-r", "report.html", "-x", "robot-xunit-results.xml", "-F", "robot",229 "--randomize", "tests:1234", "--console", "verbose", "-W", "78", "-K", "auto", "--maxerrorlines", "40"230 )231 assertAll(232 { result should haveSize(expected.size) },233 { result should containAll(expected) },234 { result shouldNot contain("none") }235 )236 }237238 @Test239 fun addPreRunModifier() {240 val result = applyConfig {241 it.preRunModifier.add("preRun")242 }.generateArguments().toList()243 val expected = createDefaults() + listOf("--prerunmodifier", "preRun")244 assertAll(245 { result should haveSize(expected.size) },246 { result should containAll(expected) }247 )248 }249250 @Test251 fun addPreRebotModifier() {252 val result = applyConfig {253 it.preRebotModifier.add("preRebot")254 }.generateArguments().toList()255 val expected = createDefaults() + listOf("--prerebotmodifier", "preRebot")256 assertAll(257 { result should haveSize(expected.size) },258 { result should containAll(expected) }259 )260 }261262 @Test263 fun changeConsoleMode() {264 val result = applyConfig {265 it.console.set("none")266 }.generateArguments().toList()267 val expected = listOf(268 "-d", Paths.get(project.buildDir.absolutePath, "reports", "robotframework").toFile().absolutePath,269 "-l", "log.html", "-r", "report.html", "-x", "robot-xunit-results.xml", "-F", "robot",270 "--randomize", "none", "--console", "none", "-W", "78", "-K", "auto", "--maxerrorlines", "40"271 )272 assertAll(273 { result should haveSize(expected.size) },274 { result should containAll(expected) },275 { result shouldNot contain("verbose") }276 )277 }278279 @Test280 fun enableDottedMode() {281 val result = applyConfig {282 it.dotted.set(true)283 }.generateArguments().toList()284 val expected = createDefaults() + listOf("-.")285 assertAll(286 { result should haveSize(expected.size) },287 { result should containAll(expected) }288 )289 }290291 @Test292 fun enableQuiteMode() {293 val result = applyConfig {294 it.quite.set(true)295 }.generateArguments().toList()296 val expected = createDefaults() + listOf("--quite")297 assertAll(298 { result should haveSize(expected.size) },299 { result should containAll(expected) }300 )301 }302303 @Test304 fun changeConsoleWidth() {305 val result = applyConfig {306 it.consoleWidth.set(10)307 }.generateArguments().toList()308 val expected = listOf(309 "-d", Paths.get(project.buildDir.absolutePath, "reports", "robotframework").toFile().absolutePath,310 "-l", "log.html", "-r", "report.html", "-x", "robot-xunit-results.xml", "-F", "robot",311 "--randomize", "none", "--console", "verbose", "-W", "10", "-K", "auto", "--maxerrorlines", "40"312 )313 assertAll(314 { result should haveSize(expected.size) },315 { result should containAll(expected) },316 { result shouldNot contain("78") }317 )318 }319320 @Test321 fun changeConsoleMarkers() {322 val result = applyConfig {323 it.consoleMarkers.set("on")324 }.generateArguments().toList()325 val expected = listOf(326 "-d", Paths.get(project.buildDir.absolutePath, "reports", "robotframework").toFile().absolutePath,327 "-l", "log.html", "-r", "report.html", "-x", "robot-xunit-results.xml", "-F", "robot",328 "--randomize", "none", "--console", "verbose", "-W", "78", "-K", "on", "--maxerrorlines", "40"329 )330 assertAll(331 { result should haveSize(expected.size) },332 { result should containAll(expected) },333 { result shouldNot contain("auto") }334 )335 }336337 private fun applyConfig(conf: (RunRobotConfiguration) -> Unit): RunRobotConfiguration {338 rf.robot(conf)339 return rf.robot.get()340 }341342 private fun createDefaultsWithoutExtensionParam() = listOf(343 "-d", Paths.get(project.buildDir.absolutePath, "reports", "robotframework").toFile().absolutePath,344 "-l", "log.html", "-r", "report.html", "-x", "robot-xunit-results.xml", "--maxerrorlines", "40",345 "--randomize", "none", "--console", "verbose", "-W", "78", "-K", "auto"346 ) ...

Full Screen

Full Screen

WineryRepositoryIT.kt

Source:WineryRepositoryIT.kt Github

copy

Full Screen

...28 "findAllForUser" should {29 "return the correct wineries" {30 val res: List<WineryWithDependencies> = repository.findAllForUser(dataSet.userOneId).collectList().block()!!31 res should haveSize(2)32 res should containAll(dataSet.petrusWineryWithDependencies, dataSet.cazeneuveWineryWithDependencies)33 }34 }35 "save" should {36 "save a new winery" {37 val newWinery = WineryEntity(UUID.randomUUID(), null, "New Winery", dataSet.languedocRegion.ID, dataSet.userOneId)38 val res = repository.save(newWinery).block()!!39 repository.findById(res.ID).block() shouldBe newWinery.copy(version = 0)40 }41 "update an existing region" {42 val updatedWinery = dataSet.cazeneuveWinery.copy(name = "Cazeneuve Winery")43 val versionBefore = updatedWinery.version()44 val res = repository.save(updatedWinery).block()!!45 res shouldBe updatedWinery.copy(version = versionBefore + 1)46 }...

Full Screen

Full Screen

RegionRepositoryIT.kt

Source:RegionRepositoryIT.kt Github

copy

Full Screen

...28 "findAllForUser" should {29 "return the correct regions" {30 val res = repository.findAllForUser(dataSet.userOneId).collectList().block()!!31 res should haveSize(3)32 res should containAll(dataSet.pomerolRegion, dataSet.picSaintLoupRegion, dataSet.languedocRegion)33 }34 }35 "save" should {36 "save a new region" {37 val newRegion = RegionEntity(UUID.randomUUID(), null, "New region", "New country", dataSet.userOneId)38 val res = repository.save(newRegion).block()!!39 repository.findById(res.ID).block() shouldBe newRegion.copy(version = 0)40 }41 "update an existing region" {42 val updatedRegion = dataSet.picSaintLoupRegion.copy(name = "Pic-St-Loup")43 val versionBefore = updatedRegion.version()44 val res = repository.save(updatedRegion).block()!!45 res shouldBe updatedRegion.copy(version = versionBefore + 1)46 }...

Full Screen

Full Screen

ScanOssResultParserTest.kt

Source:ScanOssResultParserTest.kt Github

copy

Full Screen

...17 * License-Filename: LICENSE18 */19package org.ossreviewtoolkit.scanner.scanners.scanoss20import io.kotest.core.spec.style.WordSpec21import io.kotest.matchers.collections.containAll22import io.kotest.matchers.collections.containExactlyInAnyOrder23import io.kotest.matchers.collections.haveSize24import io.kotest.matchers.should25import java.io.File26import java.time.Instant27import kotlinx.serialization.json.decodeFromStream28import org.ossreviewtoolkit.clients.scanoss.FullScanResponse29import org.ossreviewtoolkit.clients.scanoss.ScanOssService30import org.ossreviewtoolkit.model.CopyrightFinding31import org.ossreviewtoolkit.model.LicenseFinding32import org.ossreviewtoolkit.model.TextLocation33import org.ossreviewtoolkit.utils.spdx.SpdxConstants34class ScanOssResultParserTest : WordSpec({35 "generateSummary()" should {36 "properly summarize JUnit 4.12 findings" {37 val result = File("src/test/assets/scanoss-junit-4.12.json").inputStream().use {38 ScanOssService.JSON.decodeFromStream<FullScanResponse>(it)39 }40 val time = Instant.now()41 val summary = generateSummary(time, time, SpdxConstants.NONE, result)42 summary.licenses.map { it.toString() } should containExactlyInAnyOrder(43 "Apache-2.0",44 "EPL-1.0",45 "MIT",46 "LicenseRef-scancode-free-unknown",47 "LicenseRef-scanoss-SSPL"48 )49 summary.licenseFindings should haveSize(201)50 summary.licenseFindings should containAll(51 LicenseFinding(52 license = "Apache-2.0",53 location = TextLocation(54 path = "hopscotch-rails-0.1.2.1/vendor/assets/javascripts/hopscotch.js",55 startLine = TextLocation.UNKNOWN_LINE,56 endLine = TextLocation.UNKNOWN_LINE57 )58 )59 )60 summary.copyrightFindings should haveSize(7)61 summary.copyrightFindings should containAll(62 CopyrightFinding(63 statement = "Copyright 2013 LinkedIn Corp.",64 location = TextLocation(65 path = "hopscotch-rails-0.1.2.1/vendor/assets/javascripts/hopscotch.js",66 startLine = TextLocation.UNKNOWN_LINE,67 endLine = TextLocation.UNKNOWN_LINE68 )69 )70 )71 }72 }73})...

Full Screen

Full Screen

containAll.kt

Source:containAll.kt Github

copy

Full Screen

...4import io.kotest.matchers.should5import io.kotest.matchers.shouldNot6fun <T> Iterable<T>.shouldContainAll(vararg ts: T) = toList().shouldContainAll(ts)7fun <T> Array<T>.shouldContainAll(vararg ts: T) = asList().shouldContainAll(ts)8fun <T> Collection<T>.shouldContainAll(vararg ts: T) = this should containAll(*ts)9infix fun <T> Iterable<T>.shouldContainAll(ts: Collection<T>) = toList().shouldContainAll(ts)10infix fun <T> Array<T>.shouldContainAll(ts: Collection<T>) = asList().shouldContainAll(ts)11infix fun <T> Collection<T>.shouldContainAll(ts: Collection<T>) = this should containAll(ts)12fun <T> Iterable<T>.shouldNotContainAll(vararg ts: T) = toList().shouldNotContainAll(ts)13fun <T> Array<T>.shouldNotContainAll(vararg ts: T) = asList().shouldNotContainAll(ts)14fun <T> Collection<T>.shouldNotContainAll(vararg ts: T) = this shouldNot containAll(*ts)15infix fun <T> Iterable<T>.shouldNotContainAll(ts: Collection<T>) = toList().shouldNotContainAll(ts)16infix fun <T> Array<T>.shouldNotContainAll(ts: Collection<T>) = asList().shouldNotContainAll(ts)17infix fun <T> Collection<T>.shouldNotContainAll(ts: Collection<T>) = this shouldNot containAll(ts)18fun <T> containAll(vararg ts: T) = containAll(ts.asList())19fun <T> containAll(ts: Collection<T>): Matcher<Collection<T>> = object : Matcher<Collection<T>> {20 override fun test(value: Collection<T>): MatcherResult {21 val missing = ts.filterNot { value.contains(it) }22 val passed = missing.isEmpty()23 val failure =24 { "Collection should contain all of ${ts.printed().value} but was missing ${missing.printed().value}" }25 val negFailure = { "Collection should not contain all of ${ts.printed().value}" }26 return MatcherResult(passed, failure, negFailure)27 }28}...

Full Screen

Full Screen

ShouldContainAllTest.kt

Source:ShouldContainAllTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.collections2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.core.spec.style.WordSpec4import io.kotest.matchers.collections.containAll5import io.kotest.matchers.collections.shouldContainAll6import io.kotest.matchers.collections.shouldNotContainAll7import io.kotest.matchers.should8import io.kotest.matchers.throwable.shouldHaveMessage9class ShouldContainAllTest : WordSpec() {10 init {11 "containsAll" should {12 "test that a collection contains all the elements but in any order" {13 val col = listOf(1, 2, 3, 4, 5)14 col should containAll(1, 2, 3)15 col should containAll(3, 2, 1)16 col should containAll(5, 1)17 col should containAll(1, 5)18 col should containAll(1)19 col should containAll(5)20 col.shouldContainAll(1, 2, 3)21 col.shouldContainAll(3, 1)22 col.shouldContainAll(3)23 col.shouldNotContainAll(6)24 col.shouldNotContainAll(1, 6)25 col.shouldNotContainAll(6, 1)26 shouldThrow<AssertionError> {27 col should containAll(1, 2, 6)28 }29 shouldThrow<AssertionError> {30 col should containAll(6)31 }32 shouldThrow<AssertionError> {33 col should containAll(0, 1, 2)34 }35 shouldThrow<AssertionError> {36 col should containAll(3, 2, 0)37 }38 }39 "print missing elements" {40 shouldThrow<AssertionError> {41 listOf<Number>(1, 2).shouldContainAll(listOf<Number>(1L, 2L))42 }.shouldHaveMessage("""Collection should contain all of [1L, 2L] but was missing [1L, 2L]""")43 }44 }45 }46}...

Full Screen

Full Screen

UserRepositoryTests.kt

Source:UserRepositoryTests.kt Github

copy

Full Screen

1package dev.jmfayard2import io.kotest.matchers.collections.containAll3import io.kotest.matchers.should4import io.kotest.matchers.shouldBe5import kotlinx.coroutines.flow.toList6import kotlinx.coroutines.runBlocking7import org.junit.jupiter.api.AfterAll8import org.junit.jupiter.api.Assertions.assertEquals9import org.junit.jupiter.api.BeforeAll10import org.junit.jupiter.api.Test11import org.springframework.beans.factory.getBean12import org.springframework.context.ConfigurableApplicationContext13import org.springframework.fu.kofu.application14class UserRepositoryTests {15 private val dataApp = application {16 enable(dataConfig)17 }18 private lateinit var context: ConfigurableApplicationContext19 @BeforeAll20 fun beforeAll() {21 context = dataApp.run(profiles = "test")22 }23 @Test24 fun count() {25 val repository = context.getBean<UserRepository>()26 runBlocking {27 assertEquals(3, repository.count())28 }29 }30 @Test31 fun findAll() {32 val repository = context.getBean<UserRepository>()33 val expected = listOf(34 User("smaldini", "Stéphane", "Maldini"),35 User("sdeleuze", "Sébastien", "Deleuze"),36 User("bclozel", "Brian", "Clozel")37 )38 runBlocking {39 repository.findAll().toList() should containAll(expected)40 }41 }42 @AfterAll43 fun afterAll() {44 context.close()45 }46}...

Full Screen

Full Screen

containAll

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.collections.containAll2fun main(args: Array<String>) {3val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9)4list should containAll(list)5list should containAll(1, 2, 3, 4, 5, 6, 7, 8, 9)6}7Kotlin containsAll() example8Kotlin containsAll() examp

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