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

com.malinskiy.marathon.execution.Configuration.kt Maven / Gradle / Ivy

There is a newer version: 0.9.1
Show newest version
package com.malinskiy.marathon.execution

import com.malinskiy.marathon.execution.policy.ScreenRecordingPolicy
import com.malinskiy.marathon.execution.strategy.BatchingStrategy
import com.malinskiy.marathon.execution.strategy.FlakinessStrategy
import com.malinskiy.marathon.execution.strategy.PoolingStrategy
import com.malinskiy.marathon.execution.strategy.RetryStrategy
import com.malinskiy.marathon.execution.strategy.ShardingStrategy
import com.malinskiy.marathon.execution.strategy.SortingStrategy
import com.malinskiy.marathon.execution.strategy.impl.batching.IsolateBatchingStrategy
import com.malinskiy.marathon.execution.strategy.impl.flakiness.IgnoreFlakinessStrategy
import com.malinskiy.marathon.execution.strategy.impl.pooling.OmniPoolingStrategy
import com.malinskiy.marathon.execution.strategy.impl.retry.NoRetryStrategy
import com.malinskiy.marathon.execution.strategy.impl.sharding.ParallelShardingStrategy
import com.malinskiy.marathon.execution.strategy.impl.sorting.NoSortingStrategy
import com.malinskiy.marathon.vendor.VendorConfiguration
import java.io.File

private const val DEFAULT_EXECUTION_TIMEOUT_MILLIS: Long = 900_000
private const val DEFAULT_OUTPUT_TIMEOUT_MILLIS: Long = 60_000

data class Configuration constructor(
    val name: String,
    val outputDir: File,

    val analyticsConfiguration: AnalyticsConfiguration,
    val poolingStrategy: PoolingStrategy,
    val shardingStrategy: ShardingStrategy,
    val sortingStrategy: SortingStrategy,
    val batchingStrategy: BatchingStrategy,
    val flakinessStrategy: FlakinessStrategy,
    val retryStrategy: RetryStrategy,
    val filteringConfiguration: FilteringConfiguration,

    val ignoreFailures: Boolean,
    val isCodeCoverageEnabled: Boolean,
    val fallbackToScreenshots: Boolean,
    val strictMode: Boolean,
    val uncompletedTestRetryQuota: Int,

    val testClassRegexes: Collection,
    val includeSerialRegexes: Collection,
    val excludeSerialRegexes: Collection,

    val testBatchTimeoutMillis: Long,
    val testOutputTimeoutMillis: Long,
    val debug: Boolean,

    val screenRecordingPolicy: ScreenRecordingPolicy,

    val vendorConfiguration: VendorConfiguration,

    val analyticsTracking: Boolean
) {

    constructor(
        name: String,
        outputDir: File,

        analyticsConfiguration: AnalyticsConfiguration?,
        poolingStrategy: PoolingStrategy?,
        shardingStrategy: ShardingStrategy?,
        sortingStrategy: SortingStrategy?,
        batchingStrategy: BatchingStrategy?,
        flakinessStrategy: FlakinessStrategy?,
        retryStrategy: RetryStrategy?,
        filteringConfiguration: FilteringConfiguration?,

        ignoreFailures: Boolean?,
        isCodeCoverageEnabled: Boolean?,
        fallbackToScreenshots: Boolean?,
        strictMode: Boolean?,
        uncompletedTestRetryQuota: Int?,

        testClassRegexes: Collection?,
        includeSerialRegexes: Collection?,
        excludeSerialRegexes: Collection?,

        testBatchTimeoutMillis: Long?,
        testOutputTimeoutMillis: Long?,
        debug: Boolean?,

        screenRecordingPolicy: ScreenRecordingPolicy?,

        vendorConfiguration: VendorConfiguration,

        analyticsTracking: Boolean?
    ) :

            this(
                name = name,
                outputDir = outputDir,
                analyticsConfiguration = analyticsConfiguration ?: AnalyticsConfiguration.DisabledAnalytics,
                poolingStrategy = poolingStrategy ?: OmniPoolingStrategy(),
                shardingStrategy = shardingStrategy ?: ParallelShardingStrategy(),
                sortingStrategy = sortingStrategy ?: NoSortingStrategy(),
                batchingStrategy = batchingStrategy ?: IsolateBatchingStrategy(),
                flakinessStrategy = flakinessStrategy ?: IgnoreFlakinessStrategy(),
                retryStrategy = retryStrategy ?: NoRetryStrategy(),
                filteringConfiguration = filteringConfiguration ?: FilteringConfiguration(emptyList(), emptyList()),
                ignoreFailures = ignoreFailures ?: false,
                isCodeCoverageEnabled = isCodeCoverageEnabled ?: false,
                fallbackToScreenshots = fallbackToScreenshots ?: false,
                strictMode = strictMode ?: false,
                uncompletedTestRetryQuota = uncompletedTestRetryQuota ?: Integer.MAX_VALUE,
                testClassRegexes = testClassRegexes ?: listOf(Regex("^((?!Abstract).)*Test[s]*$")),
                includeSerialRegexes = includeSerialRegexes ?: emptyList(),
                excludeSerialRegexes = excludeSerialRegexes ?: emptyList(),
                testBatchTimeoutMillis = testBatchTimeoutMillis ?: DEFAULT_EXECUTION_TIMEOUT_MILLIS,
                testOutputTimeoutMillis = testOutputTimeoutMillis ?: DEFAULT_OUTPUT_TIMEOUT_MILLIS,
                debug = debug ?: true,
                screenRecordingPolicy = screenRecordingPolicy ?: ScreenRecordingPolicy.ON_FAILURE,
                vendorConfiguration = vendorConfiguration,
                analyticsTracking = analyticsTracking ?: false
            )

    fun toMap() =
        mapOf(
            "name" to name,
            "outputDir" to outputDir.absolutePath,
            "analyticsConfiguration" to analyticsConfiguration.toString(),
            "pooling" to poolingStrategy.toString(),
            "sharding" to shardingStrategy.toString(),
            "sorting" to sortingStrategy.toString(),
            "batching" to batchingStrategy.toString(),
            "flakiness" to flakinessStrategy.toString(),
            "retry" to retryStrategy.toString(),
            "filtering" to filteringConfiguration.toString(),
            "ignoreFailures" to ignoreFailures.toString(),
            "isCodeCoverageEnabled" to isCodeCoverageEnabled.toString(),
            "fallbackToScreenshots" to fallbackToScreenshots.toString(),
            "strictMode" to strictMode.toString(),
            "testClassRegexes" to testClassRegexes.toString(),
            "includeSerialRegexes" to includeSerialRegexes.toString(),
            "excludeSerialRegexes" to excludeSerialRegexes.toString(),
            "testBatchTimeoutMillis" to testBatchTimeoutMillis.toString(),
            "testOutputTimeoutMillis" to testOutputTimeoutMillis.toString(),
            "debug" to debug.toString(),
            "screenRecordingPolicy" to screenRecordingPolicy.toString(),
            "vendorConfiguration" to vendorConfiguration.toString()
        )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy