How to use sourceRef class of io.kotest.core.source package

Best Kotest code snippet using io.kotest.core.source.sourceRef

UnitSpec.kt

Source:UnitSpec.kt Github

copy

Full Screen

1package arrow.core.test2import arrow.core.NonEmptyList3import arrow.core.Tuple44import arrow.core.Tuple55import arrow.core.test.generators.unit6import arrow.core.test.laws.Law7import io.kotest.core.names.TestName8import io.kotest.core.source.SourceRef9import io.kotest.core.spec.RootTest10import io.kotest.core.spec.style.StringSpec11import io.kotest.core.spec.style.scopes.StringSpecScope12import io.kotest.core.spec.style.scopes.addTest13import io.kotest.core.test.TestType14import io.kotest.property.Arb15import io.kotest.property.Gen16import io.kotest.property.PropertyContext17import io.kotest.property.arbitrary.bind18import io.kotest.property.arbitrary.filter19import io.kotest.property.arbitrary.map20import io.kotest.property.arbitrary.list as KList21import io.kotest.property.arbitrary.map as KMap22import io.kotest.property.checkAll23import kotlin.jvm.JvmOverloads24import kotlin.math.max25/**26 * Base class for unit tests27 */28public abstract class UnitSpec(29 public val iterations: Int = 250,30 public val maxDepth: Int = 15,31 spec: UnitSpec.() -> Unit = {}32) : StringSpec() {33 public constructor(spec: UnitSpec.() -> Unit) : this(250, 15, spec)34 public fun <A> Arb.Companion.list(gen: Gen<A>, range: IntRange = 0..maxDepth): Arb<List<A>> =35 Arb.KList(gen, range)36 public fun <A> Arb.Companion.nonEmptyList(arb: Arb<A>, depth: Int = maxDepth): Arb<NonEmptyList<A>> =37 Arb.list(arb, 1..max(1, depth)).filter(List<A>::isNotEmpty).map(NonEmptyList.Companion::fromListUnsafe)38 public fun <A> Arb.Companion.sequence(arbA: Arb<A>, range: IntRange = 0..maxDepth): Arb<Sequence<A>> =39 Arb.list(arbA, range).map { it.asSequence() }40 @JvmOverloads41 public inline fun <reified A> Arb.Companion.array(gen: Arb<A>, range: IntRange = 0..maxDepth): Arb<Array<A>> =42 Arb.list(gen, range).map { it.toTypedArray() }43 public fun <K, V> Arb.Companion.map(44 keyArb: Arb<K>,45 valueArb: Arb<V>,46 minSize: Int = 1,47 maxSize: Int = 1548 ): Arb<Map<K, V>> =49 Arb.KMap(keyArb, valueArb, minSize = minSize, maxSize = maxSize)50 init {51 spec()52 }53 public fun testLaws(vararg laws: List<Law>): Unit = laws54 .flatMap { list: List<Law> -> list.asIterable() }55 .distinctBy { law: Law -> law.name }56 .forEach { law: Law ->57 addTest(TestName(null, law.name, false), false, null) {58 law.test(StringSpecScope(this.coroutineContext, testCase))59 }60 }61 public fun testLaws(prefix: String, vararg laws: List<Law>): Unit = laws62 .flatMap { list: List<Law> -> list.asIterable() }63 .distinctBy { law: Law -> law.name }64 .forEach { law: Law ->65 addTest(TestName(prefix, law.name, false), false, null) {66 law.test(StringSpecScope(this.coroutineContext, testCase))67 }68 }69 public suspend fun checkAll(property: suspend PropertyContext.() -> Unit): PropertyContext =70 checkAll(iterations, Arb.unit()) { property() }71 public suspend fun <A> checkAll(72 genA: Arb<A>,73 property: suspend PropertyContext.(A) -> Unit74 ): PropertyContext =75 checkAll(76 iterations,77 genA,78 property79 )80 public suspend fun <A, B> checkAll(81 genA: Arb<A>,82 genB: Arb<B>,83 property: suspend PropertyContext.(A, B) -> Unit84 ): PropertyContext =85 checkAll(86 iterations,87 genA,88 genB,89 property90 )91 public suspend fun <A, B, C> checkAll(92 genA: Arb<A>,93 genB: Arb<B>,94 genC: Arb<C>,95 property: suspend PropertyContext.(A, B, C) -> Unit96 ): PropertyContext =97 checkAll(98 iterations,99 genA,100 genB,101 genC,102 property103 )104 public suspend fun <A, B, C, D> checkAll(105 genA: Arb<A>,106 genB: Arb<B>,107 genC: Arb<C>,108 genD: Arb<D>,109 property: suspend PropertyContext.(A, B, C, D) -> Unit110 ): PropertyContext =111 checkAll(112 iterations,113 genA,114 genB,115 genC,116 genD,117 property118 )119 public suspend fun <A, B, C, D, E> checkAll(120 genA: Arb<A>,121 genB: Arb<B>,122 genC: Arb<C>,123 genD: Arb<D>,124 genE: Arb<E>,125 property: suspend PropertyContext.(A, B, C, D, E) -> Unit126 ): PropertyContext =127 checkAll(128 iterations,129 genA,130 genB,131 genC,132 genD,133 genE,134 property135 )136 public suspend fun <A, B, C, D, E, F> checkAll(137 genA: Arb<A>,138 genB: Arb<B>,139 genC: Arb<C>,140 genD: Arb<D>,141 genE: Arb<E>,142 genF: Arb<F>,143 property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit144 ): PropertyContext =145 checkAll(146 iterations,147 genA,148 genB,149 genC,150 genD,151 genE,152 genF,153 property154 )155 public suspend fun <A, B, C, D, E, F, G> checkAll(156 gena: Arb<A>,157 genb: Arb<B>,158 genc: Arb<C>,159 gend: Arb<D>,160 gene: Arb<E>,161 genf: Arb<F>,162 geng: Arb<G>,163 fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G) -> Unit164 ) {165 checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, ::Pair)) { a, b, c, d, e, (f, g) ->166 fn(a, b, c, d, e, f, g)167 }168 }169 public suspend fun <A, B, C, D, E, F, G, H> checkAll(170 gena: Arb<A>,171 genb: Arb<B>,172 genc: Arb<C>,173 gend: Arb<D>,174 gene: Arb<E>,175 genf: Arb<F>,176 geng: Arb<G>,177 genh: Arb<H>,178 fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) -> Unit179 ) {180 checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, genh, ::Triple)) { a, b, c, d, e, (f, g, h) ->181 fn(a, b, c, d, e, f, g, h)182 }183 }184 public suspend fun <A, B, C, D, E, F, G, H, I> checkAll(185 gena: Arb<A>,186 genb: Arb<B>,187 genc: Arb<C>,188 gend: Arb<D>,189 gene: Arb<E>,190 genf: Arb<F>,191 geng: Arb<G>,192 genh: Arb<H>,193 geni: Arb<I>,194 fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) -> Unit195 ) {196 checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, genh, geni, ::Tuple4)) { a, b, c, d, e, (f, g, h, i) ->197 fn(a, b, c, d, e, f, g, h, i)198 }199 }200 public suspend fun <A, B, C, D, E, F, G, H, I, J> checkAll(201 gena: Arb<A>,202 genb: Arb<B>,203 genc: Arb<C>,204 gend: Arb<D>,205 gene: Arb<E>,206 genf: Arb<F>,207 geng: Arb<G>,208 genh: Arb<H>,209 geni: Arb<I>,210 genj: Arb<J>,211 fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) -> Unit212 ) {213 checkAll(214 gena,215 genb,216 genc,217 gend,218 gene,219 Arb.bind(genf, geng, genh, geni, genj, ::Tuple5)220 ) { a, b, c, d, e, (f, g, h, i, j) ->221 fn(a, b, c, d, e, f, g, h, i, j)222 }223 }224 public suspend fun forFew(225 iterations: Int,226 property: suspend PropertyContext.(Unit) -> Unit227 ): PropertyContext =228 checkAll(229 iterations,230 Arb.unit(),231 property232 )233}...

Full Screen

Full Screen

sourceRef

Using AI Code Generation

copy

Full Screen

1val sourceRef = SourceRef(“MyClass.kt”, 10)2val sourceRef = SourceRef(“MyClass.kt”, 10, 5)3val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1)4val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1, 2)5val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1, 2, “MyClass.kt”)6val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1, 2, “MyClass.kt”, “MyClass.kt”)7val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1, 2, “MyClass.kt”, “MyClass.kt”, “MyClass.kt”)8val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1, 2, “MyClass.kt”, “MyClass.kt”, “MyClass.kt”, “MyClass.kt”)9val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1, 2, “MyClass.kt”, “MyClass.kt”, “MyClass.kt”, “MyClass.kt”, “MyClass.kt”)10val sourceRef = SourceRef(“MyClass.kt”, 10, 5, 1,

Full Screen

Full Screen

sourceRef

Using AI Code Generation

copy

Full Screen

1val sourceRef = SourceRef()2val testPath = TestPath(listOf("a", "b", "c"))3val descriptor = TestDescriptor(testPath, sourceRef)4val sourceRef = SourceRef()5val testPath = TestPath(listOf("a", "b", "c"))6val descriptor = TestDescriptor(testPath, sourceRef)7val sourceRef = SourceRef()8val testPath = TestPath(listOf("a", "b", "c"))9val descriptor = TestDescriptor(testPath, sourceRef)10val sourceRef = SourceRef()11val testPath = TestPath(listOf("a", "b", "c"))12val descriptor = TestDescriptor(testPath, sourceRef)13val sourceRef = SourceRef()14val testPath = TestPath(listOf("a", "b", "c"))15val descriptor = TestDescriptor(testPath, sourceRef)16val sourceRef = SourceRef()17val testPath = TestPath(listOf("a", "b", "c"))18val descriptor = TestDescriptor(testPath, sourceRef)19val sourceRef = SourceRef()20val testPath = TestPath(listOf("a", "b", "c"))21val descriptor = TestDescriptor(testPath, sourceRef)22val sourceRef = SourceRef()23val testPath = TestPath(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.

Most used methods in sourceRef

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful