All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.kotest.engine.spec.SpecExecutionOrder.kt Maven / Gradle / Ivy

package io.kotest.engine.spec

import io.kotest.core.spec.Order
import io.kotest.core.spec.SpecExecutionOrder
import io.kotest.core.spec.Spec
import io.kotest.mpp.annotation
import kotlin.reflect.KClass

interface SpecSorter {
   fun sort(classes: List>): List>
}

/**
 * An implementation of [SpecExecutionOrder] which will run specs in
 * a lexicographic order.
 */
object LexicographicSpecSorter : SpecSorter {
   override fun sort(classes: List>) = classes.sortedBy { it.simpleName }
}

/**
 * An implementation of [SpecExecutionOrder] which will run specs in
 * a different random order each time the are executed.
 */
object RandomSpecSorter : SpecSorter {
   override fun sort(classes: List>): List> = classes.shuffled()
}

object AnnotatedSpecSorter : SpecSorter {
   override fun sort(classes: List>): List> =
      classes.sortedBy { it.annotation()?.value ?: Int.MAX_VALUE }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy