How to use create method of io.kotest.matchers.string.Values class

Best Kotest code snippet using io.kotest.matchers.string.Values.create

ConversionExpressions.kt

Source:ConversionExpressions.kt Github

copy

Full Screen

...196 Regex("ArgumentCaptor.forClass\\((\n)?(\\s)*$GENERIC_GROUP::class\\.java\\)")197 private const val SLOT_REPLACEMENT = "slot<\$3>()"198 private val RULE_TEMP_FOLDER_FROM_JUNIT_REGEX =199 Regex("var $GENERIC_GROUP = TemporaryFolder\\(\\)")200 private const val RULE_TEMP_FOLDER_FROM_JUNIT_REPLACEMENT = "val \$1 = createTempDirectory()"201 private val RULE_TEMP_FILE_FROM_JUNIT_REGEX =202 Regex("$GENERIC_GROUP = $GENERIC_GROUP\\.newFile\\(\\)")203 private const val RULE_TEMP_FILE_FROM_JUNIT_REPLACEMENT = "\$1 = createTempFile(\$2).toFile()"204 private val RULE_TEMP_FILE_FROM_JUNIT_REGEX1 =205 Regex("$GENERIC_GROUP = $GENERIC_GROUP\\.newFile\\((\"$GENERIC_GROUP\"|$VARIABLE_GROUP)\\)")206 private const val RULE_TEMP_FILE_FROM_JUNIT_REPLACEMENT1 = "\$1 = Path(\$2.absolutePathString(), \$3).toFile()"207 private val KOTLIN_INJECTION_TEST_REGEX =208 Regex("(private )?(val|var) $GENERIC_GROUP: $GENERIC_GROUP\\? = null")209 private const val KOTLIN_INJECTION_TEST_REPLACE = "\$1lateinit var \$3: \$4"210 private val ANSWER_IMPLEMENTATION_FROM_MOCKITO_TO_MOCKK_TEST_REGEX =211 Regex("(\\s)*(protected )?(private )?fun $GENERIC_GROUP\\($GENERIC_GROUP\\): Answer<$GENERIC_GROUP> \\{\n*" +212 "(\\s)*return Answer \\{ $GENERIC_GROUP: InvocationOnMock\\? ->\n*" +213 "(\\s)*$GENERIC_GROUP\\(\n*" +214 "(\\s)*$GENERIC_GROUP\\)\n*" +215 "(\\s)*}\n*" +216 "(\\s)*}")217 private const val ANSWER_IMPLEMENTATION_FROM_MOCKITO_TO_MOCKK_TEST_REPLACEMENT =218 "\$1\$2\$3fun \$4(\$5): \$6 = $6(\$12)"219 private val WIREMOCK_DECLARATION_FROM_RULE_TO_INSTANCE_REGEX =220 Regex("(private )?(protected )?(var|val) $GENERIC_GROUP = WireMockRule\\($CONSTANT_GROUP\\)")221 private const val WIREMOCK_DECLARATION_FROM_RULE_TO_INSTANCE_REPLACEMENT =222 "\$1\$2\$3 \$4 = WireMockServer(options().port(\$5))"223 private val CORRECTION1_REGEX =224 Regex("$GENERIC_GROUP shouldNotBe \\($GENERIC_GROUP\\)")225 private const val CORRECTION1_REPLACEMENT = "\$1 shouldNotBe \$2"226 private val CORRECTION2_REGEX =227 Regex("$GENERIC_GROUP shouldBe \\($GENERIC_GROUP\\)")228 private const val CORRECTION2_REPLACEMENT = "\$1 shouldBe \$2"229 private val CORRECTION3_REGEX =230 Regex("$CONSTANT_GROUP2\\.capture\\(\\)")231 private const val CORRECTION3_REPLACEMENT = "capture\\(\$1\\)"232 private val CORRECTION4_REGEX =233 Regex("$GENERIC_GROUP\\.$GENERIC_GROUP\\.absolutePath\n")234 private const val CORRECTION4_REPLACEMENT = "\$1.\$2.absolutePathString()\n"235 private val CORRECTION5_REGEX =236 Regex("$GENERIC_GROUP\\.$GENERIC_GROUP\\.absolutePath\\)")237 private const val CORRECTION5_REPLACEMENT = "\$1.\$2.absolutePathString()\\)"238 private val CORRECTION60_REGEX =239 Regex("$VARIABLE_GROUP\\.newFolder\\(\\)")240 private const val CORRECTION60_REPLACEMENT = "createTempDirectory(\$1).toFile()"241 private val CORRECTION61_REGEX =242 Regex("$VARIABLE_GROUP\\.newFolder\\($CONSTANT_GROUP, $CONSTANT_GROUP, $CONSTANT_GROUP\\)")243 private const val CORRECTION61_REPLACEMENT =244 "createDirectory(\$1.resolve(\$2).createDirectory().resolve(\$3).createDirectory().resolve(\$4)).toFile()"245 private val CORRECTION62_REGEX =246 Regex("$VARIABLE_GROUP\\.newFolder\\($CONSTANT_GROUP, $CONSTANT_GROUP\\)")247 private const val CORRECTION62_REPLACEMENT =248 "createDirectory(\$1.resolve(\$2).createDirectory().resolve(\$3)).toFile()"249 private val CORRECTION6_REGEX =250 Regex("$VARIABLE_GROUP\\.newFolder\\($CONSTANT_GROUP\\)")251 private const val CORRECTION6_REPLACEMENT = "createDirectory(\$1.resolve(\$2)).toFile()"252 private val CORRECTION7_REGEX =253 Regex("$VARIABLE_GROUP\\.newFile\\($CONSTANT_GROUP\\)")254 private const val CORRECTION7_REPLACEMENT = "createFile(\$1.resolve(\$2)).toFile()"255 private val CORRECTION8_REGEX =256 Regex("$CONSTANT_GROUP2\\.root(?!\\.)")257 private const val CORRECTION8_REPLACEMENT = "\$1.toFile()"258 private val CORRECTION9_REGEX =259 Regex("root\\.toURI\\(\\).toURL\\(\\)")260 private const val CORRECTION9_REPLACEMENT = "toUri().toURL()"261 private val ASSERT_REPLACE_IMPORT_JUNIT_TO_JUPITER = mutableListOf(262 FAIL_FROM_JUNIT_TO_EXCEPTION_REGEX to (FAIL_FROM_JUNIT_TO_EXCEPTION_REPLACEMENT to arrayOf("import io.kotest.assertions.any")),263 ANY_STRING_REGEX to (ANY_STRING_REPLACEMENT to arrayOf("import io.kotest.assertions.any")),264 ANY_TYPE_REGEX to (ANY_TYPE_REPLACEMENT to arrayOf("import io.kotest.assertions.any")),265 ANY_SAME_REGEX to (ANY_SAME_REPLACEMENT to emptyArray()),266 SLOT_REGEX to (SLOT_REPLACEMENT to arrayOf("import io.mockk.slot")),267 MOCK_FROM_MOCKITO_TO_MOCKK_REGEX to (MOCK_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.mockk")),268 ASSERT_EQUAL_TO_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_EQUAL_TO_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(269 "import io.kotest.matchers.shouldBe")),270 ASSERT_GREATER_THAN_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_GREATER_THAN_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(271 "import io.kotest.matchers.ints.shouldBeGreaterThan")),272 ASSERT_TRUE_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_TRUE_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(273 "import io.kotest.matchers.booleans.shouldBeTrue")),274 ASSERT_ARRAY_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_ARRAY_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(275 "import io.kotest.matchers.collections.shouldContainExactly")),276 ASSERT_SAME_FROM_JUNIT_TO_KOTEST_REGEX0 to (ASSERT_SAME_FROM_JUNIT_TO_KOTEST_REPLACEMENT0 to arrayOf("import io.kotest.matchers.types.shouldBeSameInstanceAs")),277 ASSERT_SAME_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_SAME_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.types.shouldBeSameInstanceAs")),278 DISABLE_FROM_JUNIT_TO_KOTEST_REGEX to (DISABLE_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf("import org.junit.jupiter.api.Disabled")),279 ASSERT_FALSE_BUT_NOTEQUALS_FROM_JUNIT_TO_KOTEST_REGEX0 to (ASSERT_FALSE_BUT_NOTEQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT0 to arrayOf(280 "import io.kotest.matchers.shouldNotBe")),281 ASSERT_FALSE_BUT_NOTEQUALS_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_FALSE_BUT_NOTEQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(282 "import io.kotest.matchers.shouldNotBe")),283 ASSERT_FALSE_BUT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX0 to (ASSERT_FALSE_BUT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT0 to arrayOf(284 "import io.kotest.matchers.shouldBe")),285 ASSERT_FALSE_BUT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_FALSE_BUT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(286 "import io.kotest.matchers.shouldBe")),287 ASSERT_FALSE_BUT_NOTSAME_FROM_JUNIT_TO_KOTEST_REGEX0 to (ASSERT_FALSE_BUT_NOTSAME_FROM_JUNIT_TO_KOTEST_REPLACEMENT0 to arrayOf(288 "import io.kotest.matchers.types.shouldNotBeSameInstanceAs")),289 ASSERT_FALSE_BUT_NOTSAME_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_FALSE_BUT_NOTSAME_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(290 "import io.kotest.matchers.types.shouldNotBeSameInstanceAs")),291 ASSERT_FALSE_BUT_SAME_FROM_JUNIT_TO_KOTEST_REGEX0 to (ASSERT_FALSE_BUT_SAME_FROM_JUNIT_TO_KOTEST_REPLACEMENT0 to arrayOf(292 "import io.kotest.matchers.types.shouldBeSameInstanceAs")),293 ASSERT_FALSE_BUT_SAME_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_FALSE_BUT_SAME_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(294 "import io.kotest.matchers.types.shouldBeSameInstanceAs")),295 EVERY_THROWS_FROM_MOCKITO_TO_MOCKK_REGEX1 to (EVERY_THROWS_FROM_MOCKITO_TO_MOCKK_REPLACEMENT1 to arrayOf("import io.kotest.assertions.throwables.shouldThrow")),296 ASSERT_EMPTY_FROM_HAMCREST_TO_KOTEST_REGEX to (ASSERT_EMPTY_FROM_HAMCREST_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.collections.shouldBeEmpty")),297 ASSERT_IS_FROM_HAMCREST_TO_KOTEST_REGEX to (ASSERT_IS_FROM_HAMCREST_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.shouldBe")),298 ASSERT_HAS_SIZE_FROM_HAMCREST_TO_KOTEST_REGEX to (ASSERT_HAS_SIZE_FROM_HAMCREST_TO_KOTEST_REPLACEMENT to arrayOf(299 "import io.kotest.matchers.collections.shouldHaveSize")),300 ASSERT_NULL_VALUE_IS_IS_FROM_HAMCREST_TO_KOTEST_REGEX to (ASSERT_NULL_VALUE_IS_IS_FROM_HAMCREST_TO_KOTEST_REPLACEMENT to arrayOf(301 "import io.kotest.matchers.nulls.shouldBeNull")),302 ASSERT_NULL_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_NULL_WITH_MESSAGE_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(303 "import io.kotest.matchers.nulls.shouldBeNull")),304 ASSERT_NULL_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_NULL_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.nulls.shouldBeNull")),305 ASSERT_NOTNULL_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_NOTNULL_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.nulls.shouldNotBeNull")),306 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX5 to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT5 to arrayOf("import io.kotest.matchers.shouldBe")),307 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX4 to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT4 to arrayOf("import io.kotest.matchers.shouldBe")),308 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX3 to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT3 to arrayOf("import io.kotest.matchers.shouldBe")),309 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX0 to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT0 to arrayOf("import io.kotest.matchers.shouldBe")),310 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.shouldBe")),311 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX2 to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT2 to arrayOf("import io.kotest.matchers.shouldBe")),312 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX1 to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT1 to arrayOf("import io.kotest.matchers.shouldBe")),313 ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REGEX6 to (ASSERT_EQUALS_FROM_JUNIT_TO_KOTEST_REPLACEMENT6 to arrayOf("import io.kotest.matchers.shouldBe")),314 ASSERT_CONTAINS_STRING_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_CONTAINS_STRING_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf(315 "import io.kotest.matchers.string.shouldContain")),316 EVERY_THEN_FROM_MOCKITO_TO_MOCKK_REGEX to (EVERY_THEN_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.every")),317 EVERY_TRUE_FROM_MOCKITO_TO_MOCKK_REGEX to (EVERY_TRUE_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.every")),318 EVERY_TRUE_FROM_MOCKITO_TO_MOCKK_REGEX1 to (EVERY_TRUE_FROM_MOCKITO_TO_MOCKK_REPLACEMENT1 to arrayOf("import io.mockk.every")),319 EVERY_THROWS_FROM_MOCKITO_TO_MOCKK_REGEX0 to (EVERY_THROWS_FROM_MOCKITO_TO_MOCKK_REPLACEMENT0 to arrayOf("import io.mockk.every",320 "import io.mockk.mockk")),321 EVERY_THROWS_FROM_MOCKITO_TO_MOCKK_REGEX to (EVERY_THROWS_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.every")),322 VERIFY_ATLEAST_FROM_MOCKITO_TO_MOCKK_REGEX to (VERIFY_ATLEAST_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.verify")),323 VERIFY_TIMES_FROM_MOCKITO_TO_MOCKK_REGEX to (VERIFY_TIMES_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.verify")),324 VERIFY_SIMPLE_FROM_MOCKITO_TO_MOCKK_REGEX0 to (VERIFY_SIMPLE_FROM_MOCKITO_TO_MOCKK_REPLACEMENT0 to arrayOf("import io.mockk.verify")),325 VERIFY_SIMPLE_FROM_MOCKITO_TO_MOCKK_REGEX to (VERIFY_SIMPLE_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.verify")),326 VERIFY_SIMPLE_FROM_MOCKITO_TO_MOCKK_REGEX1 to (VERIFY_SIMPLE_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf("import io.mockk.verify")),327 RULE_TEMP_FOLDER_FROM_JUNIT_REGEX to (RULE_TEMP_FOLDER_FROM_JUNIT_REPLACEMENT to arrayOf("import kotlin.io.path.createTempDirectory")),328 RULE_TEMP_FILE_FROM_JUNIT_REGEX to (RULE_TEMP_FILE_FROM_JUNIT_REPLACEMENT to arrayOf("import kotlin.io.path.createTempFile")),329 RULE_TEMP_FILE_FROM_JUNIT_REGEX1 to (RULE_TEMP_FILE_FROM_JUNIT_REPLACEMENT1 to emptyArray()),330 KOTLIN_INJECTION_TEST_REGEX to (KOTLIN_INJECTION_TEST_REPLACE to emptyArray()),331 ASSERT_FALSE_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_FALSE_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.booleans.shouldBeFalse")),332 ASSERT_TRUE_FROM_JUNIT_TO_KOTEST_REGEX to (ASSERT_TRUE_FROM_JUNIT_TO_KOTEST_REPLACEMENT to arrayOf("import io.kotest.matchers.booleans.shouldBeTrue")),333 ANSWER_IMPLEMENTATION_FROM_MOCKITO_TO_MOCKK_TEST_REGEX to (ANSWER_IMPLEMENTATION_FROM_MOCKITO_TO_MOCKK_TEST_REPLACEMENT to emptyArray()),334 EVERY_THEN_WITH_INVOCATION_ARGS_FROM_MOCKITO_TO_MOCKK_REGEX to (EVERY_THEN_WITH_INVOCATION_ARGS_FROM_MOCKITO_TO_MOCKK_REPLACEMENT to arrayOf(335 "import io.mockk.every")),336 WIREMOCK_DECLARATION_FROM_RULE_TO_INSTANCE_REGEX to (WIREMOCK_DECLARATION_FROM_RULE_TO_INSTANCE_REPLACEMENT to arrayOf(337 "import com.github.tomakehurst.wiremock.WireMockServer",338 "import com.github.tomakehurst.wiremock.core.WireMockConfiguration.options")),339 CORRECTION1_REGEX to (CORRECTION1_REPLACEMENT to emptyArray()),340 CORRECTION2_REGEX to (CORRECTION2_REPLACEMENT to emptyArray()),341 CORRECTION3_REGEX to (CORRECTION3_REPLACEMENT to emptyArray()),342 CORRECTION4_REGEX to (CORRECTION4_REPLACEMENT to arrayOf("import kotlin.io.path.absolutePathString")),343 CORRECTION5_REGEX to (CORRECTION5_REPLACEMENT to arrayOf("import kotlin.io.path.absolutePathString")),344 CORRECTION60_REGEX to (CORRECTION60_REPLACEMENT to arrayOf("import kotlin.io.path.createTempDirectory")),345 CORRECTION61_REGEX to (CORRECTION61_REPLACEMENT to arrayOf("import java.nio.file.Files.createDirectory",346 "import java.nio.file.Files.createDirectory",347 "import kotlin.io.path.createDirectory")),348 CORRECTION62_REGEX to (CORRECTION62_REPLACEMENT to arrayOf("import java.nio.file.Files.createDirectory",349 "import java.nio.file.Files.createDirectory","import kotlin.io.path.createDirectory")),350 CORRECTION6_REGEX to (CORRECTION6_REPLACEMENT to arrayOf("import kotlin.io.path.Path",351 "import kotlin.io.path.absolutePathString", "import java.nio.file.Files.createDirectory")),352 CORRECTION7_REGEX to (CORRECTION7_REPLACEMENT to arrayOf("import kotlin.io.path.Path",353 "import kotlin.io.path.absolutePathString", "import java.nio.file.Files.createFile")),354 CORRECTION8_REGEX to (CORRECTION8_REPLACEMENT to emptyArray()),355 CORRECTION9_REGEX to (CORRECTION9_REPLACEMENT to emptyArray()),356 )357 private val IMPORT_REPLACEMENT_JUNIT_TO_JUPITER = mapOf(358 Regex("import org.junit.Before") to "import org.junit.jupiter.api.BeforeEach",359 Regex("import org.junit.Test") to "import org.junit.jupiter.api.Test",360 Regex("import org.junit.runner.RunWith") to "import org.junit.jupiter.api.extension.ExtendWith",361 Regex("import org.mockito.junit.MockitoJUnitRunner") to "import io.mockk.junit5.MockKExtension",362 Regex("import org.mockito.Mock\n") to "import io.mockk.impl.annotations.MockK\n",363 Regex("import org.junit.Assert(;)?\n") to "",364 Regex("import org.junit.runner.RunWith(;)?\n") to "",365 Regex("import org.hamcrest.Matchers(;)?\n") to "",366 Regex("import org.hamcrest.core.IsNull(;)?\n") to "",367 Regex("import org.hamcrest.MatcherAssert(;)?\n") to "",...

Full Screen

Full Screen

ConversionExpressionsKtTest.kt

Source:ConversionExpressionsKtTest.kt Github

copy

Full Screen

...102 """.trimIndent()103 val processTests = test.processTests104 processTests shouldBe """105 $PACKAGE106 import kotlin.io.path.createTempFile107 import org.junit.jupiter.api.Test108 val racoonFile = Path(racoonFileCabinet.absolutePathString(), fileName).toFile()109 val bonoboFile = createTempFile(bonoboFileCabinet).toFile()110 """.trimIndent()111 }112 @Test113 fun `should convert invocation args mockito method`() {114 val test = """115 $PACKAGE116 import org.junit.jupiter.api.Test117 Mockito.`when`(bananaService.getPackagePerRef(ArgumentMatchers.anyString())).then { invocation ->118 val crates = invocation.arguments[0].toString()119 val bananas = openCrates(crates)120 Contents(crates, bananas, nBonobos)121 }122 """.trimIndent()123 val processTests = test.processTests124 processTests shouldBe """125 $PACKAGE126 import io.kotest.assertions.any127 import io.mockk.every128 import org.junit.jupiter.api.Test129 every { bananaService.getPackagePerRef(any<String>()) } answers {130 val crates = it.invocation.args[0].toString()131 val bananas = openCrates(crates)132 Contents(crates, bananas, nBonobos)133 }134 """.trimIndent()135 }136 @Test137 fun `should return test shouldBeTrue`() {138 val test = """139 $PACKAGE140 import org.junit.Test141 Assert.assertTrue(RacoonsBonobos(badRacoons, badMojo).racoonsBonobos!!.kanjer.isDom)142 """.trimIndent()143 val processTests = test.processTests144 processTests shouldBe """145 $PACKAGE146 import io.kotest.matchers.booleans.shouldBeTrue147 import org.junit.jupiter.api.Test148 RacoonsBonobos(badRacoons, badMojo).racoonsBonobos!!.kanjer.isDom.shouldBeTrue()149 """.trimIndent()150 }151 @Test152 fun `should generate test with right order shouldBe`() {153 val test = """154 $PACKAGE155 import org.junit.Test156 Assert.assertEquals(ex.cause!!.javaClass, GoodException::class.java)157 """.trimIndent()158 val processTests = test.processTests159 processTests shouldBe """160 $PACKAGE161 import io.kotest.matchers.shouldBe162 import org.junit.jupiter.api.Test163 ex.cause!!.javaClass shouldBe GoodException::class.java164 """.trimIndent()165 }166 @Test167 fun `should generate test from Rule`() {168 val test = """169 $PACKAGE170 import org.junit.Test171 import org.junit.rules.TemporaryFolder172 import org.junit.Rule173 @Rule174 var wilderness = TemporaryFolder()175 bonobo = wilderness.newFile()176 """.trimIndent()177 val processTests = test.processTests178 processTests shouldBe """179 $PACKAGE180 import kotlin.io.path.createTempDirectory181 import kotlin.io.path.createTempFile182 import org.junit.jupiter.api.Test183 val wilderness = createTempDirectory()184 bonobo = createTempFile(wilderness).toFile()185 """.trimIndent()186 }187 @Test188 fun `should convert to late init var`() {189 val test = """190 $PACKAGE191 import org.junit.jupiter.api.Test192 val racoonService: RacoonService? = null193 private val bonoboService: BonoboService? = null194 """.trimIndent()195 val processTests = test.processTests196 processTests shouldBe """197 $PACKAGE198 import org.junit.jupiter.api.Test199 lateinit var racoonService: RacoonService200 private lateinit var bonoboService: BonoboService201 """.trimIndent()202 }203 @Test204 fun `should convert expected Exception Test`() {205 val test = """206 $PACKAGE207 import org.junit.jupiter.api.Test208 @Test(expected = CreationException::class)209 fun testCreateParkFailTest() {210 createRacoonWildPark().doItNow(211 now)212 }213 """.trimIndent()214 val processTests = test.processTests215 processTests shouldBe """216 $PACKAGE217 import io.kotest.assertions.throwables.shouldThrow218 import org.junit.jupiter.api.Test219 @Test220 fun testCreateParkFailTest() {221 shouldThrow<CreationException> { createRacoonWildPark().doItNow(now) }222 }223 """.trimIndent()224 }225 @Test226 fun `should convert Mockito then answers`() {227 val test = """228 $PACKAGE229 import org.junit.jupiter.api.Test230 Mockito.`when`(racoonMock!!.create(nest!!)).then(createMockNest(mockMaterials))231 """.trimIndent()232 val processTests = test.processTests233 processTests shouldBe """234 $PACKAGE235 import io.mockk.every236 import org.junit.jupiter.api.Test237 every { racoonMock!!.create(nest!!) } answers { createMockNest(mockMaterials) }238 """.trimIndent()239 }240 @Test241 fun `should convert answer implementation method`() {242 val test = """243 $PACKAGE244 import org.junit.jupiter.api.Test245 private fun bonoboAnswer(name: String?): Answer<Bonobo> {246 return Answer { invocation: InvocationOnMock? ->247 Bonobo(248 banana, game, clock))249 }250 }251 """.trimIndent()252 val processTests = test.processTests253 processTests shouldBe """254 $PACKAGE255 import org.junit.jupiter.api.Test256 private fun bonoboAnswer(name: String?): Bonobo = Bonobo(banana, game, clock))257 """.trimIndent()258 }259 @Test260 fun `should convert new Folder creation`() {261 val test = """262 $PACKAGE263 import org.junit.jupiter.api.Test264 Mockito.`when`(bonono.camp).thenReturn(archive.newFolder("racoon"))265 """.trimIndent()266 val processTests = test.processTests267 processTests shouldBe """268 $PACKAGE269 import io.mockk.every270 import java.nio.file.Files.createDirectory271 import kotlin.io.path.Path272 import kotlin.io.path.absolutePathString273 import org.junit.jupiter.api.Test274 every { bonono.camp } returns createDirectory(archive.resolve("racoon")).toFile()275 """.trimIndent()276 }277 companion object {278 const val PACKAGE = "package org.jesperancinha.plugins.unit"279 }280}...

Full Screen

Full Screen

EvolutionaryExtensionsTest.kt

Source:EvolutionaryExtensionsTest.kt Github

copy

Full Screen

...33 "calculate mean value of population" {34 // given35 val lowerBound = 0.036 val upperBound = 7.037 val solution1 = createSolution(listOf(1.0, 2.0, 3.0), lowerBound, upperBound)38 val solution2 = createSolution(listOf(4.0, 5.0, 6.0), lowerBound, upperBound)39 val population = Population(listOf(solution1, solution2))40 // when41 val meanSolution = population.average()42 // then43 meanSolution shouldNotBe null44 meanSolution?.shouldHaveSize(3)45 meanSolution?.get(0)?.value shouldBe 2.546 meanSolution?.get(1)?.value shouldBe 3.547 meanSolution?.get(2)?.value shouldBe 4.548 meanSolution?.forAll {49 it.lowerBound shouldBe lowerBound50 it.upperBound shouldBe upperBound51 }52 }53 "redundant variables check (with respect to min distance" {54 // given55 val lowerBound = 0.056 val upperBound = 7.057 val variables1 = createVariables(listOf(1.0, 2.0, 3.0), lowerBound, upperBound)58 val variables2 = createVariables(listOf(4.0, 5.0, 6.0), lowerBound, upperBound)59 // when distance is ~5.196160 val notRedundantDistance = variables1.redundant(variables2, 5.0)61 val redundantDistance = variables1.redundant(variables2, 5.2)62 // then63 notRedundantDistance shouldBe false64 redundantDistance shouldBe true65 }66 "mean Accumulator value is calculated correctly (preserving min NFE metric)" {67 // given68 val accumulator1 =69 createAccumulator(70 mapOf(71 "Hypervolume" to listOf(1.0, 2.0, 3.0, 4.0),72 "IGD" to listOf(4.0, 5.0, 6.0),73 "NFE" to listOf(1001.0, 2000.0, 3002.0)74 )75 )76 val accumulator2 =77 createAccumulator(78 mapOf(79 "Hypervolume" to listOf(4.0, 5.0, 6.0),80 "IGD" to listOf(7.0, 8.0, 10.0),81 "NFE" to listOf(1000.0, 2005.0, 3000.0)82 )83 )84 val accumulators = listOf(accumulator1, accumulator2)85 // when86 val meanAccumulator = accumulators.average()87 // then88 meanAccumulator.size("Hypervolume") shouldBe 389 meanAccumulator["Hypervolume", 0] shouldBe 2.590 meanAccumulator["Hypervolume", 1] shouldBe 3.591 meanAccumulator["Hypervolume", 2] shouldBe 4.592 meanAccumulator.size("IGD") shouldBe 393 meanAccumulator["IGD", 0] shouldBe 5.594 meanAccumulator["IGD", 1] shouldBe 6.595 meanAccumulator["IGD", 2] shouldBe 896 meanAccumulator.size("NFE") shouldBe 397 meanAccumulator["NFE", 0] shouldBe 1000.098 meanAccumulator["NFE", 1] shouldBe 2000.099 meanAccumulator["NFE", 2] shouldBe 3000.0100 }101})102fun createAccumulator(resultsData: Map<String, List<Double>>): Accumulator {103 val accumulator = Accumulator()104 resultsData.keys.forEach { metric ->105 resultsData[metric]?.forEach { accumulator.add(metric, it) }106 }107 return accumulator108}109fun createSolution(values: List<Double>, lowerBound: Double, upperBound: Double): Solution =110 createVariables(values, lowerBound, upperBound)111 .let { variables ->112 Solution(3, 0).apply {113 variables.indices.forEach { setVariable(it, variables[it]) }114 }115 }116private fun createVariables(117 values: List<Double>,118 lowerBound: Double,119 upperBound: Double120) = values.map { RealVariable(it, lowerBound, upperBound) }...

Full Screen

Full Screen

LuceneDocumentTest.kt

Source:LuceneDocumentTest.kt Github

copy

Full Screen

...11import org.apache.lucene.document.DoubleRange12import org.apache.lucene.document.FloatRange13import java.net.InetAddress14class LuceneDocumentTest : ShouldSpec({15 should("buildDocument should create an empty document") {16 buildDocument { }.fields shouldHaveSize 017 }18 should("storeFields should activate the store option for relevant fields") {19 val doc = buildDocument {20 storeFields {21 stringField("field", "test")22 }23 }24 doc.getField("field").fieldType().stored() shouldBe true25 }26 should("indexFields should deactivate the store option for relevant fields ") {27 val doc = buildDocument {28 indexFields {29 stringField("field", "test")30 }31 }32 doc.getField("field").fieldType().stored() shouldBe false33 }34 should("stringField should create a StringField in the document") {35 dummyDocument { storeFields { stringField("field", "test") } }.first().shouldBeTypeOf<StringField>()36 }37 should("textField should create a TextField in the document") {38 dummyDocument { storeFields { textField("field", "test") } }.first().shouldBeTypeOf<TextField>()39 }40 should("Document should contain fields and singular values") {41 val doc = buildDocument {42 storeFields {43 stringField("field1", "string")44 stringField("field3", "asd", "dsa")45 }46 }47 doc.getField("field1").stringValue() shouldBe "string"48 doc.getValues("field3") shouldContainAll listOf("asd", "dsa")49 }50 should("point should create point field in the document") {51 dummyDocument { storeFields { point("field", 1) } }.first().shouldBeTypeOf<IntPoint>()52 dummyDocument { storeFields { point("field", 1L) } }.first().shouldBeTypeOf<LongPoint>()53 dummyDocument { storeFields { point("field", 1F) } }.first().shouldBeTypeOf<FloatPoint>()54 dummyDocument { storeFields { point("field", 1.0) } }.first().shouldBeTypeOf<DoublePoint>()55 }56 should("range should create range field in the document") {57 dummyDocument { storeFields { range("field", listOf(1.toInt()), listOf(2.toInt())) } }.first()58 .shouldBeTypeOf<IntRange>()59 dummyDocument { storeFields { range("field", listOf(1L), listOf(2L)) } }.first().shouldBeTypeOf<LongRange>()60 dummyDocument { storeFields { range("field", listOf(1F), listOf(2F)) } }.first().shouldBeTypeOf<FloatRange>()61 dummyDocument { storeFields { range("field", listOf(1.0), listOf(2.0)) } }.first().shouldBeTypeOf<DoubleRange>()62 }63 should("xyPoint should create XYPointField field in the document") {64 val stored = dummyDocument { storeFields { xyPoint("field", 1F, 1F) } }65 stored.first().shouldBeTypeOf<XYPointField>()66 stored.second().shouldBeTypeOf<XYDocValuesField>()67 val notStored = dummyDocument { indexFields { xyPoint("field", 1F, 1F) } }68 notStored.first().shouldBeTypeOf<XYPointField>()69 shouldThrow<NoSuchElementException> { notStored.second() }70 }71 should("feature should create FeatureField field in the document") {72 dummyDocument { storeFields { feature("field", "featureName", 1F) } }.first().shouldBeTypeOf<FeatureField>()73 }74 should("knnVector should create KnnVectorField field in the document") {75 dummyDocument { storeFields { knnVector("field", floatArrayOf(1f, 2F)) } }.first()76 .shouldBeTypeOf<KnnVectorField>()77 }78 should("inetAddressPoint should create InetAddressPoint field in the document") {79 dummyDocument { storeFields { inetAddressPoint("field", InetAddress.getLocalHost()) } }.first()80 .shouldBeTypeOf<InetAddressPoint>()81 }82 should("inetAddressRange should create InetAddressRange field in the document") {83 dummyDocument {84 storeFields {85 inetAddressRange(86 "field",87 InetAddress.getLocalHost(),88 InetAddress.getLocalHost()89 )90 }91 }.first().shouldBeTypeOf<InetAddressRange>()92 }93})...

Full Screen

Full Screen

V1TableMapperUnitTest.kt

Source:V1TableMapperUnitTest.kt Github

copy

Full Screen

...13class V1TableMapperUnitTest {14 private val backend = MockDynamoBackend()15 private val mapper = DynamoDBMapper(MockDynamoDbV1(backend))16 .newTableMapper<DynamoCat, Int, String>(DynamoCat::class.java)17 .also { it.createTable(ProvisionedThroughput(1, 1)) }18 private val toggles = DynamoCat(2, "Toggles", "female")19 private val smokey = DynamoCat(1, "Smokey", "female")20 private val bandit = DynamoCat(1, "Bandit", "male")21 @Test22 fun `scan empty`() {23 mapper.scan(DynamoDBScanExpression()).shouldBeEmpty()24 }25 @Test26 fun `scan all`() {27 mapper.batchSave(setOf(toggles, smokey, bandit)).shouldBeEmpty()28 mapper.scan(DynamoDBScanExpression()).shouldContainExactlyInAnyOrder(bandit, smokey, toggles)29 }30 @Test31 fun `scan with EQ filter`() {...

Full Screen

Full Screen

AutoFieldTest.kt

Source:AutoFieldTest.kt Github

copy

Full Screen

...22 assertSoftly {23 shouldThrow<PSQLException> {24 it.execute(25 """26 insert into hymn.core_biz_object_field (biz_object_id, name, api, type,gen_rule, create_by_id, 27 create_by, modify_by_id, modify_by, create_date, modify_date) 28 values (?,${randomFieldNameAndApi("auto")},null,?,?,?,?,now(),now()) returning *;29 """,30 objId,31 *COMMON_INFO32 )33 }.message shouldContain "[f:inner:08800] 编号规则不能为空"34 }35 }36 }37 @Test38 fun `there can only be one placeholder in gen_rul`() {39 customBizObject {40 shouldThrow<PSQLException> {41 it.execute(42 """43 insert into hymn.core_biz_object_field (biz_object_id, name, api, type,gen_rule, create_by_id, 44 create_by, modify_by_id, modify_by, create_date, modify_date) 45 values (?,${randomFieldNameAndApi("auto")},'{00}{000}',?,?,?,?,now(),now()) returning *;46 """,47 objId, *COMMON_INFO48 )49 }.message shouldContain "[f:inner:08900] 编号规则中有且只能有一个{0}占位符"50 }51 }52 @Test53 fun auto() {54 customBizObject {55 val field = it.execute(56 """57 insert into hymn.core_biz_object_field (biz_object_id, name, api, type,gen_rule, create_by_id, 58 create_by, modify_by_id, modify_by, create_date, modify_date) 59 values (?,${randomFieldNameAndApi("auto")},'{yyyy}{mm}{000}',?,?,?,?,now(),now()) returning *;60 """,61 objId,62 *COMMON_INFO63 )[0]64 (field["source_column"] as String) shouldStartWith "text"65 it.fieldShouldExists(field["api"])66 it.execute(67 """68 insert into hymn_view.${objApi} (create_date,modify_date,owner_id,create_by_id,69 modify_by_id,type_id,${field["api"]}) 70 values (now(), now(), ?, ?, ?, ?, ?) returning *;""",71 *standardField, ""72 ).apply {73 size shouldBe 174 val now = LocalDate.now()75 this[0][field["api"]] as String shouldMatch "^${now.year}${now.monthValue}\\d{3}"76 }77 }78 }79}...

Full Screen

Full Screen

StampsAndCoinsGeneratorKtTest.kt

Source:StampsAndCoinsGeneratorKtTest.kt Github

copy

Full Screen

...43 getRandomNameWithChars(100) shouldMatch "[a-z0-9\\ ]*"44 }45 "list generation" should {46 "generate list of 10 stamps" {47 val listOfStamps = createListOfStamps(10)48 listOfStamps shouldHaveSize 1049 }50 "generate list of 10 coins" {51 val listOfCoins = createListOfCoins(10)52 listOfCoins shouldHaveSize 1053 }54 }55 "creating objects" should {56 "create coin with params" {57 val coin = Coin(1, "desc", 1900, 10, Currency.PTE, 10, 0)58 coin.id shouldBeEqualComparingTo 159 coin.description shouldBeEqualComparingTo "desc"60 coin.year shouldBeEqualComparingTo 190061 coin.value shouldBeEqualComparingTo 1062 coin.currency shouldBeEqualComparingTo Currency.PTE63 coin.diameterMM shouldBeExactly 1064 coin.internalDiameterMM shouldBeExactly 065 }66 "create stamp with params" {67 val stamp = Stamp(1, "desc", 1900, 10, Currency.PTE, 10, 20)68 stamp.id shouldBeExactly 169 stamp.description shouldBeEqualComparingTo "desc"70 stamp.year shouldBeExactly 190071 stamp.value shouldBeExactly 1072 stamp.currency shouldBeEqualComparingTo Currency.PTE73 stamp.heightMM shouldBeExactly 1074 stamp.widthMM shouldBeExactly 2075 }76 }77 }78}...

Full Screen

Full Screen

MyTests.kt

Source:MyTests.kt Github

copy

Full Screen

...12 "world" should startWith("wor")13 }14 "check config sizes" {15 val config = GameConfig(2, 1, 1, 5)16 val players = config.create()17 players.size shouldBe config.size18 }19 fun zeroTypeMsgs() = PlayerType.values().map { "No $it" }20 fun wrongNumber() = PlayerType.values().map { "Wrong number of $it" }21 "invalid mafia config sizes" {22 val exception =23 shouldThrow<IllegalStateException> {24 GameConfig(0, 1, 1, 5).create()25 }26 exception.message shouldBeIn zeroTypeMsgs()27 }28 "invalid villager config sizes" {29 val exception =30 shouldThrow<IllegalStateException> {31 GameConfig(2, 1, 1, 0).create()32 }33 exception.message shouldBeIn zeroTypeMsgs()34 }35 "invalid angel config sizes" {36 val exception =37 shouldThrow<IllegalStateException> {38 GameConfig(2, 0, 1, 5).create()39 }40 exception.message shouldBeIn wrongNumber()41 }42 "invalid detective config sizes" {43 val exception =44 shouldThrow<IllegalStateException> {45 GameConfig(2, 1, 0, 5).create()46 }47 exception.message shouldBeIn wrongNumber()48 }49})...

Full Screen

Full Screen

create

Using AI Code Generation

copy

Full Screen

1assertThat ( "abc" ). create (). contains ( "a" , "b" , "c" )2assertThat ( "abc" ). create (). containsExactly ( "a" , "b" , "c" )3assertThat ( "abc" ). create (). containsExactlyInAnyOrder ( "a" , "b" , "c" )4assertThat ( "abc" ). create (). containsInAnyOrder ( "a" , "b" , "c" )5assertThat ( "abc" ). create (). containsNone ( "d" , "e" , "f" )6assertThat ( "abc" ). create (). containsOnly ( "a" , "b" , "c" )7assertThat ( "abc" ). create (). containsOnlyOnce ( "a" , "b" , "c" )8assertThat ( "abc" ). create (). containsOnlyOnceInAnyOrder ( "a" , "b" , "c" )9assertThat ( "abc" ). create (). containsOnlyOnceInOrder ( "a" , "b" , "c" )10assertThat ( "abc" ). create (). containsOnlyOnceInOrder ( "a" , "b" , "c" )11assertThat ( "abc" ). create (). containsOnlyOnceInOrder ( "a" , "b" , "c" )12assertThat ( "abc" ). create (). containsOnlyOnceInOrder ( "a" , "b" , "c" )

Full Screen

Full Screen

create

Using AI Code Generation

copy

Full Screen

1println("2val values = Values("hello", "world", "kotlin", "java", "scala")3values.create("hello", "world", "kotlin", "java", "scala")4println("5values.shouldNotContain("c++", "python", "javascript")6println("7values.shouldContain("kotlin", "java", "scala")8println("9values.shouldContainAll("kotlin", "java", "scala")10println("11values.shouldContainAny("kotlin", "java", "scala")12println("13values.shouldContainNone("c++", "python", "javascript")14println("15values.shouldContainOnly("kotlin", "java", "scala")16println("17values.shouldContainNoneInOrder("c++", "python", "javascript")18println("19values.shouldContainAllInOrder("kotlin", "java", "scala")20println("

Full Screen

Full Screen

create

Using AI Code Generation

copy

Full Screen

1Values.create(expected)2fun main(args: Array<String>) { val expected = "Kotlin" val actual = "Kotlin" val values = Values.create(expected) println(values.test(actual)) }3Values.test(actual)4fun main(args: Array<String>) { val expected = "Kotlin" val actual = "Kotlin" val values = Values.create(expected) println(values.test(actual)) }5Values.toString()6fun main(args: Array<String>) { val expected = "Kotlin" val actual = "Kotlin" val values = Values.create(expected) println(values.toString()) }7Values(expected=Kotlin)8Values.equals(other)9fun main(args: Array<String>) { val expected = "Kotlin" val actual = "Kotlin" val values = Values.create(expected) println(values.equals(actual)) }10Values.hashCode()11fun main(args: Array<String>) { val expected = "Kotlin

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