How to use A.shouldBeLowerCase method of io.kotest.matchers.string.case class

Best Kotest code snippet using io.kotest.matchers.string.case.A.shouldBeLowerCase

matchers.kt

Source:matchers.kt Github

copy

Full Screen

1package tutorial.kotest2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.assertions.throwables.shouldThrowAny4import io.kotest.assertions.throwables.shouldThrowExactly5import io.kotest.core.spec.style.DescribeSpec6import io.kotest.core.test.AssertionMode7import io.kotest.matchers.booleans.shouldBeTrue8import io.kotest.matchers.collections.shouldBeIn9import io.kotest.matchers.collections.shouldBeOneOf10import io.kotest.matchers.collections.shouldBeSameSizeAs11import io.kotest.matchers.collections.shouldBeSingleton12import io.kotest.matchers.collections.shouldBeSmallerThan13import io.kotest.matchers.collections.shouldBeSorted14import io.kotest.matchers.collections.shouldBeUnique15import io.kotest.matchers.collections.shouldContain16import io.kotest.matchers.collections.shouldContainAll17import io.kotest.matchers.collections.shouldContainAnyOf18import io.kotest.matchers.collections.shouldContainDuplicates19import io.kotest.matchers.collections.shouldContainExactly20import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder21import io.kotest.matchers.collections.shouldContainInOrder22import io.kotest.matchers.collections.shouldContainNull23import io.kotest.matchers.collections.shouldEndWith24import io.kotest.matchers.collections.shouldHaveAtLeastSize25import io.kotest.matchers.collections.shouldHaveLowerBound26import io.kotest.matchers.collections.shouldHaveSingleElement27import io.kotest.matchers.collections.shouldHaveSize28import io.kotest.matchers.collections.shouldHaveUpperBound29import io.kotest.matchers.collections.shouldNotContainAnyOf30import io.kotest.matchers.collections.shouldNotHaveElementAt31import io.kotest.matchers.collections.shouldStartWith32import io.kotest.matchers.comparables.shouldBeEqualComparingTo33import io.kotest.matchers.comparables.shouldBeLessThanOrEqualTo34import io.kotest.matchers.date.shouldBeToday35import io.kotest.matchers.date.shouldHaveSameHoursAs36import io.kotest.matchers.doubles.Percentage37import io.kotest.matchers.doubles.beNaN38import io.kotest.matchers.doubles.plusOrMinus39import io.kotest.matchers.doubles.shouldBeNaN40import io.kotest.matchers.doubles.shouldNotBeNaN41import io.kotest.matchers.equality.shouldBeEqualToComparingFields42import io.kotest.matchers.equality.shouldBeEqualToComparingFieldsExcept43import io.kotest.matchers.equality.shouldBeEqualToIgnoringFields44import io.kotest.matchers.equality.shouldBeEqualToUsingFields45import io.kotest.matchers.file.shouldBeADirectory46import io.kotest.matchers.file.shouldBeAbsolute47import io.kotest.matchers.file.shouldExist48import io.kotest.matchers.file.shouldNotBeEmpty49import io.kotest.matchers.ints.beOdd50import io.kotest.matchers.ints.shouldBeBetween51import io.kotest.matchers.ints.shouldBeInRange52import io.kotest.matchers.ints.shouldBeLessThan53import io.kotest.matchers.ints.shouldBeLessThanOrEqual54import io.kotest.matchers.ints.shouldBeOdd55import io.kotest.matchers.ints.shouldBePositive56import io.kotest.matchers.ints.shouldBeZero57import io.kotest.matchers.iterator.shouldBeEmpty58import io.kotest.matchers.iterator.shouldHaveNext59import io.kotest.matchers.maps.shouldBeEmpty60import io.kotest.matchers.maps.shouldContain61import io.kotest.matchers.maps.shouldContainAll62import io.kotest.matchers.maps.shouldContainExactly63import io.kotest.matchers.maps.shouldContainKey64import io.kotest.matchers.nulls.shouldBeNull65import io.kotest.matchers.nulls.shouldNotBeNull66import io.kotest.matchers.shouldBe67import io.kotest.matchers.shouldNot68import io.kotest.matchers.shouldNotBe69import io.kotest.matchers.string.beEmpty70import io.kotest.matchers.string.shouldBeBlank71import io.kotest.matchers.string.shouldBeEmpty72import io.kotest.matchers.string.shouldBeEqualIgnoringCase73import io.kotest.matchers.string.shouldBeInteger74import io.kotest.matchers.string.shouldBeLowerCase75import io.kotest.matchers.string.shouldBeUpperCase76import io.kotest.matchers.string.shouldContain77import io.kotest.matchers.string.shouldContainADigit78import io.kotest.matchers.string.shouldContainIgnoringCase79import io.kotest.matchers.string.shouldContainOnlyDigits80import io.kotest.matchers.string.shouldContainOnlyOnce81import io.kotest.matchers.string.shouldEndWith82import io.kotest.matchers.string.shouldHaveLength83import io.kotest.matchers.string.shouldHaveLineCount84import io.kotest.matchers.string.shouldHaveMaxLength85import io.kotest.matchers.string.shouldHaveMinLength86import io.kotest.matchers.string.shouldHaveSameLengthAs87import io.kotest.matchers.string.shouldMatch88import io.kotest.matchers.string.shouldNotBeEmpty89import io.kotest.matchers.string.shouldStartWith90import io.kotest.matchers.throwable.shouldHaveCause91import io.kotest.matchers.throwable.shouldHaveCauseInstanceOf92import io.kotest.matchers.throwable.shouldHaveCauseOfType93import io.kotest.matchers.throwable.shouldHaveMessage94import io.kotest.matchers.types.shouldBeInstanceOf95import io.kotest.matchers.types.shouldBeSameInstanceAs96import io.kotest.matchers.types.shouldBeTypeOf97import io.kotest.matchers.uri.shouldHaveHost98import io.kotest.matchers.uri.shouldHavePort99import io.kotest.matchers.uri.shouldHaveScheme100import java.io.File101import java.net.URI102import java.time.LocalDate103import java.time.LocalTime104// https://kotest.io/docs/assertions/core-matchers.html105class MatchersTest : DescribeSpec({106 describe("general") {107 it("basics") {108 (1 == 1).shouldBeTrue()109 (2 + 2) shouldBe 4110 val foo: Any = "foobar"111 foo.shouldBeTypeOf<String>() shouldContain "fo"112 "".shouldBeEmpty()113 "x".shouldNot(beEmpty()) // manually negate114 "x".shouldNotBeEmpty() // reusable115 URI("https://tba") shouldHaveHost "tba"116 URI("https://tba:81") shouldHavePort 81117 URI("https://tba") shouldHaveScheme "https"118 File("/").apply {119 shouldExist()120 shouldBeADirectory()121 shouldBeAbsolute()122 shouldNotBeEmpty()123 }124 // executable, hidden, readable, smaller, writeable, containFile, extension, path, ...125 LocalDate.now().shouldBeToday()126 // before/after, within, same, between, have year/month/day/hour/...127 LocalTime.now().shouldHaveSameHoursAs(LocalTime.now())128 // before/after/between, sameMinute/Seconds/Nanos129 }130 it("numbers") {131 1 shouldBeLessThan 2132 1 shouldBeLessThanOrEqual 1 // Int-based; returns this133 1 shouldBeLessThanOrEqualTo 1 // Comparble-based; void134 1 shouldBeEqualComparingTo 1 // Comparable-based135 1.shouldBeBetween(0, 2)136 1 shouldBeInRange 0..2137 0.shouldBeZero()138 1.shouldBePositive()139 1.shouldBeOdd()140 (1.2).shouldBe(1.20001.plusOrMinus(Percentage(20.0)))141 (1.2).shouldNotBeNaN()142 }143 it("strings") {144 // generic: "abc" shouldBe "abc"145 "aBc" shouldBeEqualIgnoringCase "abc"146 "".shouldBeEmpty()147 " ".shouldBeBlank() // empty or whitespace148 "abc" shouldContain ("b")149 "aBc" shouldContainIgnoringCase "bc"150 "x-a-x" shouldContain """\-[a-z]\-""".toRegex()151 "-a-" shouldMatch """\-[a-z]\-""".toRegex()152 "abc" shouldStartWith ("a")153 "abc" shouldEndWith ("c")154 "ab aa" shouldContainOnlyOnce "aa"155 "abc".shouldBeLowerCase()156 "ABC".shouldBeUpperCase()157 "abc" shouldHaveLength 3158 "a\nb" shouldHaveLineCount 2159 "ab" shouldHaveMinLength 1 shouldHaveMaxLength 3160 "abc" shouldHaveSameLengthAs "foo"161 "1".shouldBeInteger()162 "12".shouldContainOnlyDigits()163 "abc1".shouldContainADigit() // at least one164 }165 it("types") {166 @Connotation167 open class SuperType()168 class SubType : SuperType()169 val sameRef = SuperType()170 sameRef.shouldBeSameInstanceAs(sameRef)171 val superType: SuperType = SubType()172 superType.shouldBeTypeOf<SubType>() // exact runtime match (SuperType won't work!)173 superType.shouldBeInstanceOf<SuperType>() // T or below174// SubType().shouldHaveAnnotation(Connotation::class)175 val nullable: String? = null176 nullable.shouldBeNull()177 }178 it("collections") {179 emptyList<Int>().iterator().shouldBeEmpty()180 listOf(1).iterator().shouldHaveNext()181 listOf(1, 2) shouldContain 1 // at least182 listOf(1, 2) shouldContainExactly listOf(1, 2) // in-order; not more183 listOf(1, 2) shouldContainExactlyInAnyOrder listOf(2, 1) // out-order; not more184 listOf(0, 3, 0, 4, 0).shouldContainInOrder(3, 4) // possible items in between185 listOf(1) shouldNotContainAnyOf listOf(2, 3) // black list186 listOf(1, 2, 3) shouldContainAll listOf(3, 2) // out-order; more187 listOf(1, 2, 3).shouldBeUnique() // no duplicates188 listOf(1, 2, 2).shouldContainDuplicates() // at least one duplicate189 listOf(1, 2).shouldNotHaveElementAt(1, 3)190 listOf(1, 2) shouldStartWith 1191 listOf(1, 2) shouldEndWith 2192 listOf(1, 2) shouldContainAnyOf listOf(2, 3)193 val x = SomeType(1)194 x shouldBeOneOf listOf(x) // by reference/instance195 x shouldBeIn listOf(SomeType(1)) // by equality/structural196 listOf(1, 2, null).shouldContainNull()197 listOf(1) shouldHaveSize 1198 listOf(1).shouldBeSingleton() // size == 1199 listOf(1).shouldBeSingleton {200 it.shouldBeOdd()201 }202 listOf(1).shouldHaveSingleElement {203 beOdd().test(it).passed() // have to return a boolean here :-/204 }205 listOf(2, 3) shouldHaveLowerBound 1 shouldHaveUpperBound 4206 listOf(1) shouldBeSmallerThan listOf(1, 2)207 listOf(1) shouldBeSameSizeAs listOf(2)208 listOf(1, 2) shouldHaveAtLeastSize 1209 listOf(1, 2).shouldBeSorted()210 mapOf(1 to "a").shouldContain(1, "a") // at least this211 mapOf(1 to "a") shouldContainAll mapOf(1 to "a") // at least those212 mapOf(1 to "a") shouldContainExactly mapOf(1 to "a") // not more213 mapOf(1 to "a") shouldContainKey 1214 emptyMap<Any, Any>().shouldBeEmpty()215 }216 it("exceptions") {217 class SubException() : Exception()218 Exception("a") shouldHaveMessage "a" // same (not contains!)219 Exception("abc").message shouldContain "b"220 Exception("", Exception()).shouldHaveCause()221 Exception("symptom", Exception("cause")).shouldHaveCause {222 it.message shouldBe "cause"223 }224 Exception("", SubException()).shouldHaveCauseInstanceOf<Exception>() // T or subclass225 Exception("", SubException()).shouldHaveCauseOfType<SubException>() // exactly T226 shouldThrow<Exception> { // type or subtype227 throw SubException()228 }229 shouldThrowExactly<Exception> { // exactly that type (no subtype!)230 throw Exception()231 }232 shouldThrowAny { // don't care which233 throw Exception()234 }235 }236 }237 describe("advanced") {238 it("selective matcheres") {239 data class Foo(val p1: Int, val p2: Int)240 val foo1 = Foo(1, 1)241 val foo2 = Foo(1, 2)242 foo1.shouldBeEqualToUsingFields(foo2, Foo::p1)243 foo1.shouldBeEqualToIgnoringFields(foo2, Foo::p2)244 class Bar(val p1: Int, val p2: Int) // not a data class! no equals.245 val bar1a = Bar(1, 1)246 val bar1b = Bar(1, 1)247 bar1a shouldNotBe bar1b248 bar1a shouldBeEqualToComparingFields bar1b // "fake equals" (ignoring private properties)249 bar1a.shouldBeEqualToComparingFields(bar1b, false) // explicitly also check private props250 val bar2 = Bar(1, 2)251 bar1a.shouldBeEqualToComparingFieldsExcept(bar2, Bar::p2)252 }253 }254 // channels255 // concurrent, futures256 // result, optional257 // threads258 // reflection259 // statistic, regex260})261private data class SomeType(val value: Int = 1)262private annotation class Connotation...

Full Screen

Full Screen

KotlinTest.kt

Source:KotlinTest.kt Github

copy

Full Screen

1package com.example.sampletestcode2import io.kotest.core.spec.style.*3import io.kotest.matchers.collections.sorted4import io.kotest.matchers.should5import io.kotest.matchers.shouldBe6import io.kotest.matchers.string.*7import io.kotest.matchers.collections.beEmpty8import io.kotest.matchers.maps.contain9import io.kotest.matchers.maps.haveKey10import io.kotest.matchers.maps.haveValue11class StringSpecTest : StringSpec() {12 // StringSpec를 상속 받으며, 보통 init 블럭 내에서 테스트 코드를 작성한다.13 // init 블록 내부의 문자열은 테스트를 설명하는 부분이며, 블럭 내부의 코드가 실제 테스트가 진행되는 부분이다.14 init {15 "문자열.length가 문자열의 길이를 리턴해야 합니다." {16 "kotlin test".length shouldBe 1117 }18 }19}20class FunSpecTest : FunSpec({21 // FunSpec는 함수 형태로 테스트 코드를 작성할 수 있도록 돕는다.22 // 테스트 함수의 매개 변수는 단순 테스트 설명이며, 테스트 함수 내부의 코드가 실제 테스트가 진행되는 부분이다.23 test("문자열의 길이를 리턴해야 합니다.") {24 "kotlin".length shouldBe 625 "".length shouldBe 026 }27})28class ShouldSpecTest : ShouldSpec({29 // ShouldSpec는 FunSpec과 유사하다. 다만, test 대신 should 키워드를 사용한다는 차이점이 있다.30 // 아래 should 의 매개 변수는 단순 설명이고, 테스트는 역시 블럭 내부에서 동작한다.31 should("문자열의 길이를 리턴해야 합니다.") {32 "kotlin".length shouldBe 633 "".length shouldBe 034 }35})36class WordSpecTest : WordSpec({37 // String.length 부분은 context string이다. 어떠한 환경에서 테스트를 진행할 것인지를 말해 주는 것이다.38 // 아래 한글은 역시 설명 부분이며, 코드 블럭 내부에서 실제 테스트가 동작한다.39 "String.length" should {40 "문자열의 길이를 리턴해야 합니다." {41 "kotlin".length shouldBe 642 "".length shouldBe 043 }44 }45})46class BehaviorSpecTest : BehaviorSpec({47 // BehaviorSpec는 BDD (Behaviour Driven Development)48 given("젓가락") {49 `when`("잡는다.") {50 then("음식을 먹는다.") {51 println("젓가락을 잡고, 음식을 먹는다.")52 }53 }54 `when`("던진다.") {55 then("사람이 맞는다.") {56 println("젓가락을 던지면, 사람이 맞는다.")57 }58 }59 }60})61class AnnotationSpecTest : AnnotationSpec() {62 // AnnotationSpec는 JUnit 스타일(PersonTest 파일 참고)로 테스트 코드를 작성할 수 있다.63 @BeforeEach64 fun beforeTest() {65 println("Before Test, Setting")66 }67 @Test68 fun test1() {69 "test".length shouldBe 470 }71 @Test72 fun test2() {73 "test2".length shouldBe 574 }75}76class MatcherTest : StringSpec() {77 init {78 // shouldBe는 동일함을 체크하는 Matcher 이다.79 "hello World" shouldBe haveLength(11) // length가 매개변수에 전달된 값이어야 함을 체크한다.80 "hello" should include("ll") // 매개변수 값이 포함되어 있는지 확인한다.81 "hello" should endWith("lo") // 매개변수의 끝이 포함되는지 확인한다.82 "hello" should match("he...") // 매개변수가 매칭되는지 체크한다.83 "hello".shouldBeLowerCase() // 소문자로 작성된 것이 맞는지 체크한다.84 val list = emptyList<String>()85 val list2 = listOf("aaa", "bbb", "ccc")86 val map = mapOf<String, String>(Pair("aa", "11"))87 list should beEmpty() // 원소가 비었는지 확인한다.88 list2 shouldBe sorted<String>() // 해당 자료형이 정렬되어 있는지 확인한다.89 map should contain("aa", "11") // 해당 원소가 포함되어 있는지 확인한다.90 map should haveKey("aa") // 해당 키 값이 포함되어 있는지 확인한다.91 map should haveValue("11") // 해당 value 값이 포함되어 있는지 확인한다.92 }93}...

Full Screen

Full Screen

AssertSoftlyIntentionTest.kt

Source:AssertSoftlyIntentionTest.kt Github

copy

Full Screen

1package io.kotest.plugin.intellij.intentions2import com.intellij.openapi.command.CommandProcessor3import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase4import io.kotest.matchers.shouldBe5import org.jetbrains.kotlin.idea.core.moveCaret6import org.jetbrains.kotlin.idea.util.application.runWriteAction7import java.nio.file.Paths8class AssertSoftlyIntentionTest : LightJavaCodeInsightFixtureTestCase() {9 override fun getTestDataPath(): String {10 val path = Paths.get("./src/test/resources/").toAbsolutePath()11 return path.toString()12 }13 fun testIntentionForPartialSelectedMultipleLines() {14 myFixture.configureByFiles(15 "/intentions/assert_softly.kt",16 "/io/kotest/core/spec/style/specs.kt"17 )18 editor.moveCaret(905)19 editor.selectionModel.setSelection(905, 955)20 val intention = myFixture.findSingleIntention("Surround statements with soft assert")21 intention.familyName shouldBe "Surround statements with soft assert"22 CommandProcessor.getInstance().runUndoTransparentAction {23 runWriteAction {24 intention.invoke(project, editor, file)25 }26 }27 file.text shouldBe """package io.kotest.samples.gradle28import io.kotest.core.spec.style.FunSpec29import io.kotest.matchers.string.shouldBeLowerCase30import io.kotest.matchers.string.shouldBeUpperCase31import io.kotest.matchers.string.shouldNotBeBlank32import io.kotest.assertions.assert.assertSoftly33class FunSpecExampleTest : FunSpec({34 test("a string cannot be blank") {35 "wibble".shouldNotBeBlank()36 }37 test("a string should be lower case").config(enabled = true) {38 "wibble".shouldBeLowerCase()39 }40 context("some context") {41 test("a string cannot be blank") {42 "wibble".shouldNotBeBlank()43 }44 test("a string should be lower case").config(enabled = true) {45 "wibble".shouldBeLowerCase()46 }47 context("another context") {48 test("a string cannot be blank") {49 "wibble".shouldNotBeBlank()50 }51 test("a string should be lower case").config(enabled = true) {52 assertSoftly {53 "wibble".shouldBeLowerCase()54 "WOBBLE".shouldBeUpperCase()55 }56 }57 }58 }59})60"""61 }62 fun testIntentionForFullLine() {63 myFixture.configureByFiles(64 "/intentions/assert_softly.kt",65 "/io/kotest/core/spec/style/specs.kt"66 )67 editor.moveCaret(523)68 editor.selectionModel.setSelection(523, 558)69 val intention = myFixture.findSingleIntention("Surround statements with soft assert")70 intention.familyName shouldBe "Surround statements with soft assert"71 CommandProcessor.getInstance().runUndoTransparentAction {72 runWriteAction {73 intention.invoke(project, editor, file)74 }75 }76 file.text shouldBe """package io.kotest.samples.gradle77import io.kotest.core.spec.style.FunSpec78import io.kotest.matchers.string.shouldBeLowerCase79import io.kotest.matchers.string.shouldBeUpperCase80import io.kotest.matchers.string.shouldNotBeBlank81import io.kotest.assertions.assert.assertSoftly82class FunSpecExampleTest : FunSpec({83 test("a string cannot be blank") {84 "wibble".shouldNotBeBlank()85 }86 test("a string should be lower case").config(enabled = true) {87 "wibble".shouldBeLowerCase()88 }89 context("some context") {90 test("a string cannot be blank") {91 assertSoftly {92 "wibble".shouldNotBeBlank()93 }94 }95 test("a string should be lower case").config(enabled = true) {96 "wibble".shouldBeLowerCase()97 }98 context("another context") {99 test("a string cannot be blank") {100 "wibble".shouldNotBeBlank()101 }102 test("a string should be lower case").config(enabled = true) {103 "wibble".shouldBeLowerCase()104 "WOBBLE".shouldBeUpperCase()105 }106 }107 }108})109"""110 }111}...

Full Screen

Full Screen

AssertionsTest.kt

Source:AssertionsTest.kt Github

copy

Full Screen

1package com.example.demo.assertions2import io.kotest.assertions.assertSoftly3import io.kotest.core.spec.style.StringSpec4import io.kotest.matchers.collections.shouldContain5import io.kotest.matchers.collections.shouldContainAll6import io.kotest.matchers.shouldBe7import io.kotest.matchers.shouldNot8import io.kotest.matchers.shouldNotBe9import io.kotest.matchers.string.shouldBeLowerCase10import io.kotest.matchers.string.shouldContain11import io.kotest.matchers.string.shouldEndWith12import io.kotest.matchers.string.shouldStartWith13import org.junit.jupiter.api.assertThrows14class AssertionsTest : StringSpec({15 "simple matchers test" {16 "".length.shouldBe(0)17 "".length shouldBe 018 "a".shouldNotBe("")19 "a" shouldNotBe ""20 val numbers = listOf(1, 2, 3, 4, 5)21 numbers.shouldContain(3)22 numbers shouldContain 323 numbers.shouldContainAll(listOf(1, 2, 3, 4, 5))24 numbers shouldContainAll listOf(1, 2, 3, 4, 5)25 "hello kotest".shouldStartWith("hello")26 "hello kotest" shouldStartWith "hello"27 "hello kotest".shouldEndWith("kotest")28 "hello kotest" shouldEndWith "kotest"29 }30 "multitude of matchers test" {31 val imageUrl = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"32 imageUrl.shouldContain("google")33 .shouldStartWith("https")34 .shouldEndWith(".png")35 .shouldBeLowerCase()36 }37 "exceptions test" {38 assertThrows<NumberFormatException> {39 "test".toInt()40 }41 val actual = assertThrows<Exception> {42 throw Exception("test message")43 }44 actual.message shouldBe "test message"45 }46 "soft assertions test" {47 val sut = Person(48 name = "james",49 age = 30,50 email = "test@gmail.com",51 phone = "010-1111-2222"52 )53 assertSoftly(sut) {54 name shouldBe "james"55 age shouldBe 3056 email shouldBe "test@gmail.com"57 phone shouldBe "010-1111-2222"58 }59 }60})61class Person(62 val name: String,63 val age: Int,64 val email: String,65 val phone: String,66)...

Full Screen

Full Screen

MatcherTest.kt

Source:MatcherTest.kt Github

copy

Full Screen

1package com.psg.kotest_example2import io.kotest.core.spec.style.StringSpec3import io.kotest.matchers.collections.sorted4import io.kotest.matchers.maps.contain5import io.kotest.matchers.maps.haveKey6import io.kotest.matchers.maps.haveValue7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import io.kotest.matchers.string.*10class MatcherTest : StringSpec() {11 init {12 // 'shouldBe' 동일함을 체크하는 Matcher 입니다.13 "hello world" shouldBe haveLength(11) // length가 11이어야 함을 체크 합니다.14 "hello" should include("ll") // 파라미터가 포함되어 있는지 체크 합니다.15 "hello" should endWith("lo") // 파라미터가 끝의 포함되는지 체크 합니다.16 "hello" should match("he...") // 파라미터가 매칭되는지 체크 합니다.17 "hello".shouldBeLowerCase() // 소문자로 작성되었는지 체크 합니다.18 val list = emptyList<String>()19 val list2 = listOf("aaa", "bbb", "ccc")20 val map = mapOf<String, String>(Pair("aa", "11"))21 list should beEmpty() // 원소가 비었는지 체크 합니다.22 list2 shouldBe sorted<String>() // 해당 자료형이 정렬 되었는지 체크 합니다.23 map should contain("aa", "11") // 해당 원소가 포함되었는지 체크 합니다.24 map should haveKey("aa") // 해당 key가 포함되었는지 체크 합니다.25 map should haveValue("11") // 해당 value가 포함되었는지 체크 합니다.26 }27}...

Full Screen

Full Screen

LowercaseTest.kt

Source:LowercaseTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.string2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.core.spec.style.FreeSpec4import io.kotest.matchers.should5import io.kotest.matchers.shouldBe6import io.kotest.matchers.shouldNot7import io.kotest.matchers.string.beLowerCase8import io.kotest.matchers.string.shouldBeLowerCase9import io.kotest.matchers.string.shouldNotBeLowerCase10class LowercaseTest : FreeSpec({11 "string should beLowerCase()" - {12 "should test that a string is lower case" {13 "" should beLowerCase()14 "hello" should beLowerCase()15 "HELLO" shouldNot beLowerCase()16 "HELlo" shouldNot beLowerCase()17 "hello".shouldBeLowerCase()18 "HELLO".shouldNotBeLowerCase()19 }20 "should support char seqs" {21 val cs = "HELLO"22 cs.shouldNotBeLowerCase()23 val cs2 = "hello"24 cs2.shouldBeLowerCase()25 }26 "should support nullable char seqs" {27 val cs: CharSequence? = "HELLO"28 cs.shouldNotBeLowerCase()29 val cs2: CharSequence? = "hello"30 cs2.shouldBeLowerCase()31 }32 "should fail if value is null" {33 shouldThrow<AssertionError> {34 null shouldNot beLowerCase()35 }.message shouldBe "Expecting actual not to be null"36 shouldThrow<AssertionError> {37 null.shouldNotBeLowerCase()38 }.message shouldBe "Expecting actual not to be null"39 shouldThrow<AssertionError> {40 null should beLowerCase()41 }.message shouldBe "Expecting actual not to be null"42 shouldThrow<AssertionError> {43 null.shouldBeLowerCase()44 }.message shouldBe "Expecting actual not to be null"45 }46 }47})...

Full Screen

Full Screen

case.kt

Source:case.kt Github

copy

Full Screen

1package io.kotest.matchers.string2import io.kotest.assertions.print.print3import io.kotest.matchers.Matcher4import io.kotest.matchers.MatcherResult5import io.kotest.matchers.neverNullMatcher6import io.kotest.matchers.should7import io.kotest.matchers.shouldNot8fun <A : CharSequence> A?.shouldBeUpperCase(): A {9 this should beUpperCase()10 return this!!11}12fun <A : CharSequence> A?.shouldNotBeUpperCase(): A {13 this shouldNot beUpperCase()14 return this!!15}16fun beUpperCase(): Matcher<CharSequence?> = neverNullMatcher { value ->17 MatcherResult(18 value.toString().uppercase() == value,19 { "${value.print().value} should be upper case" },20 {21 "${value.print().value} should not should be upper case"22 })23}24fun <A : CharSequence?> A.shouldBeLowerCase(): A {25 this should beLowerCase()26 return this27}28fun <A : CharSequence?> A.shouldNotBeLowerCase(): A {29 this shouldNot beLowerCase()30 return this31}32fun beLowerCase(): Matcher<CharSequence?> = neverNullMatcher { value ->33 MatcherResult(34 value.toString().lowercase() == value,35 { "${value.print().value} should be lower case" },36 {37 "${value.print().value} should not should be lower case"38 })39}...

Full Screen

Full Screen

assert_softly.kt

Source:assert_softly.kt Github

copy

Full Screen

1package io.kotest.samples.gradle2import io.kotest.core.spec.style.FunSpec3import io.kotest.matchers.string.shouldBeLowerCase4import io.kotest.matchers.string.shouldBeUpperCase5import io.kotest.matchers.string.shouldNotBeBlank6class FunSpecExampleTest : FunSpec({7 test("a string cannot be blank") {8 "wibble".shouldNotBeBlank()9 }10 test("a string should be lower case").config(enabled = true) {11 "wibble".shouldBeLowerCase()12 }13 context("some context") {14 test("a string cannot be blank") {15 "wibble".shouldNotBeBlank()16 }17 test("a string should be lower case").config(enabled = true) {18 "wibble".shouldBeLowerCase()19 }20 context("another context") {21 test("a string cannot be blank") {22 "wibble".shouldNotBeBlank()23 }24 test("a string should be lower case").config(enabled = true) {25 "wibble".shouldBeLowerCase()26 "WOBBLE".shouldBeUpperCase()27 }28 }29 }30})...

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