Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add failure message to uncompleted test result #859

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/ProjectExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.gradle.kotlin.dsl.withType
import org.gradle.testing.jacoco.tasks.JacocoReport
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun Project.setupKotlinCompiler(jvmTarget: String = "1.8") {
fun Project.setupKotlinCompiler(jvmTarget: String = "11") {
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = jvmTarget
kotlinOptions.apiVersion = "1.5"
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object Versions {
val allureJava = "2.24.0"
val allureKotlin = "2.4.0"
val allureEnvironment = "1.0.0"
val mockitoKotlin = "2.2.0"
val mockitoKotlin = "5.1.0"
val dokka = "1.9.10"
val koin = "3.5.0"
val jsonAssert = "1.5.1"
Expand Down Expand Up @@ -114,7 +114,7 @@ object TestLibraries {

val junit = "junit:junit:${Versions.junit}"

val mockitoKotlin = "com.nhaarman.mockitokotlin2:mockito-kotlin:${Versions.mockitoKotlin}"
val mockitoKotlin = "org.mockito.kotlin:mockito-kotlin:${Versions.mockitoKotlin}"
val jupiterEngine = "org.junit.jupiter:junit-jupiter-engine:${Versions.jupiterEngine}"
val koin = "io.insert-koin:koin-test:${Versions.koin}"
val jsonAssert = "org.skyscreamer:jsonassert:${Versions.jsonAssert}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.malinskiy.marathon.config.serialization
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
Expand Down Expand Up @@ -41,6 +42,7 @@ class ConfigurationFactory(
.build()
)
registerModule(JavaTimeModule())
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
},
private val environmentVariableSubstitutor: StringSubstitutor = StringSubstitutor(StringLookupFactory.INSTANCE.environmentVariableStringLookup()),
private val analyticsTracking: Boolean? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.malinskiy.marathon.config.serialization

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
Expand Down Expand Up @@ -29,6 +30,7 @@ class MutableConfigurationFactory {
.build()
)
registerModule(JavaTimeModule())
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
}

fun parse(value: String) = mapper.readValue(value, Configuration.Builder::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.malinskiy.marathon.config.strategy

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import java.time.Instant
Expand All @@ -17,9 +18,9 @@ import java.time.Instant
sealed class BatchingStrategyConfiguration {
data class FixedSizeBatchingStrategyConfiguration(
val size: Int,
val durationMillis: Long? = null,
val percentile: Double? = null,
val timeLimit: Instant? = null,
@JsonInclude(JsonInclude.Include.NON_NULL) val durationMillis: Long? = null,
@JsonInclude(JsonInclude.Include.NON_NULL) val percentile: Double? = null,
@JsonInclude(JsonInclude.Include.NON_NULL) val timeLimit: Instant? = null,
val lastMileLength: Int = 0
) : BatchingStrategyConfiguration()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.malinskiy.marathon.config.environment

import com.malinskiy.marathon.cli.args.environmentConfiguration
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.mock
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.kotlin.whenever
import java.io.File

class SystemEnvironmentReaderTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import com.malinskiy.marathon.config.vendor.android.ScreenshotConfiguration
import com.malinskiy.marathon.config.vendor.android.SerialStrategy
import com.malinskiy.marathon.config.vendor.android.TimeoutConfiguration
import com.malinskiy.marathon.config.vendor.android.VideoConfiguration
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.mock
import org.amshove.kluent.`should be equal to`
import org.amshove.kluent.shouldBe
import org.amshove.kluent.shouldBeEmpty
Expand All @@ -41,6 +40,7 @@ import org.amshove.kluent.shouldThrow
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.mockito.kotlin.whenever
import java.io.File
import java.time.Duration
import java.time.Instant
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
package com.malinskiy.marathon.config.serialization

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.KotlinFeature
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.malinskiy.marathon.config.LogicalConfigurationValidator
import com.malinskiy.marathon.config.serialization.time.InstantTimeProvider
import com.malinskiy.marathon.config.serialization.time.InstantTimeProviderImpl
import com.malinskiy.marathon.config.serialization.yaml.SerializeModule
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.io.TempDir
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import java.io.File
import java.nio.file.Path
import java.time.Instant

class ConfigurationSerializationTest {

val validator = LogicalConfigurationValidator()

val referenceInstant: Instant = Instant.now()
private val mockInstantTimeProvider = object : InstantTimeProvider {
override fun referenceTime(): Instant = referenceInstant
}

lateinit var parser: ConfigurationFactory
lateinit var mapper: ObjectMapper

@ValueSource(
strings = arrayOf(
Expand All @@ -28,9 +49,6 @@ class ConfigurationSerializationTest {
"android/sample_3.yaml",
"android/sample_4.yaml",
"android/sample_5.yaml",
//should fail due to no xctestrun file
//"sample_5.yaml"
//"ios/sample_1.yaml",
"ios/sample_1.yaml",
"ios/sample_2.yaml",
"ios/sample_3.yaml",
Expand All @@ -40,14 +58,38 @@ class ConfigurationSerializationTest {
fun testSimple(path: String, @TempDir tempDir: Path) {
val file = File(ConfigurationSerializationTest::class.java.getResource("/fixture/config/${path}").file)

val configurationFactory = ConfigurationFactory(file.parentFile)
val parsedConfiguration = configurationFactory.parse(file)
val marathonfileDir = file.parentFile
mapper = ObjectMapper(
YAMLFactory()
.disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID)
).apply {
setSerializationInclusion(JsonInclude.Include.NON_NULL)
registerModule(SerializeModule(mockInstantTimeProvider, marathonfileDir))
registerModule(
KotlinModule.Builder()
.withReflectionCacheSize(512)
.configure(KotlinFeature.NullToEmptyCollection, false)
.configure(KotlinFeature.NullToEmptyMap, false)
.configure(KotlinFeature.NullIsSameAsDefault, false)
.configure(KotlinFeature.SingletonSupport, true)
.configure(KotlinFeature.StrictNullChecks, false)
.build()
)
registerModule(JavaTimeModule())
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
}
parser = ConfigurationFactory(
marathonfileDir = marathonfileDir,
mapper = mapper,
)

val parsedConfiguration = parser.parse(file)

val serializedYaml = configurationFactory.serialize(parsedConfiguration)
val serializedYaml = parser.serialize(parsedConfiguration)
val tempFile = File(tempDir.toFile(), "temp")
tempFile.writeText(serializedYaml)

val recreatedConfiguration = configurationFactory.parse(tempFile)
val recreatedConfiguration = parser.parse(tempFile)

parsedConfiguration shouldBeEqualTo recreatedConfiguration
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import com.malinskiy.marathon.config.environment.EnvironmentConfiguration
import com.malinskiy.marathon.config.environment.EnvironmentReader
import com.malinskiy.marathon.config.exceptions.ConfigurationException
import com.malinskiy.marathon.config.serialization.ConfigurationFactory
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.mock
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.mockito.kotlin.whenever
import java.io.File

class AndroidConfigurationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class TestRunResultsAccumulator(private val timer: Timer) {
TestStatus.INCOMPLETE,
lastCompletedTestEndTime,
timer.currentTimeMillis(),
runFailureMessage
runFailureMessage ?: "Test didn't complete. Either the test results are missing due to timeout or testing runtime crashed"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

package com.malinskiy.marathon.analytics.external.graphite

import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.never
import com.nhaarman.mockitokotlin2.verify
import org.mockito.kotlin.mock
import org.junit.jupiter.api.Test
import org.mockito.kotlin.any
import org.mockito.kotlin.eq
import org.mockito.kotlin.never
import org.mockito.kotlin.verify

class BasicGraphiteClientTest {
private val host = "host"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.malinskiy.marathon.analytics.metrics.remote.graphite

import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.any
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldEqual
import org.amshove.kluent.shouldEqualTo
import org.junit.jupiter.api.Test
import org.mockito.kotlin.whenever
import java.time.Instant

internal class GraphiteDataSourceTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.malinskiy.marathon.analytics.metrics.remote.influx

import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.any
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldEqual
import org.amshove.kluent.shouldEqualTo
import org.influxdb.InfluxDB
import org.influxdb.dto.Query
import org.influxdb.dto.QueryResult
import org.junit.jupiter.api.Test
import org.mockito.kotlin.whenever
import java.time.Instant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import com.malinskiy.marathon.analytics.metrics.remote.RemoteDataSource
import com.malinskiy.marathon.analytics.metrics.remote.SuccessRate
import com.malinskiy.marathon.generateTest
import com.malinskiy.marathon.test.toSafeTestName
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.mock
import org.amshove.kluent.shouldEqualTo
import org.junit.jupiter.api.Test
import org.mockito.kotlin.eq
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoMoreInteractions
import org.mockito.kotlin.whenever
import java.time.Instant

class MetricsProviderImplTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import com.malinskiy.marathon.execution.TestShard
import com.malinskiy.marathon.execution.TestStatus
import com.malinskiy.marathon.generateTest
import com.malinskiy.marathon.report.getDevice
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.reset
import org.mockito.kotlin.mock
import org.mockito.kotlin.reset
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import com.malinskiy.marathon.execution.TestResult
import com.malinskiy.marathon.execution.TestShard
import com.malinskiy.marathon.execution.TestStatus
import com.malinskiy.marathon.execution.progress.PoolProgressAccumulator
import com.nhaarman.mockitokotlin2.KArgumentCaptor
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.argumentCaptor
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.reset
import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
import org.mockito.kotlin.KArgumentCaptor
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.mock
import org.mockito.kotlin.reset
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import com.malinskiy.marathon.execution.TestShard
import com.malinskiy.marathon.execution.TestStatus
import com.malinskiy.marathon.execution.progress.PoolProgressAccumulator
import com.malinskiy.marathon.generateTest
import com.nhaarman.mockitokotlin2.inOrder
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.reset
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import org.mockito.kotlin.inOrder
import org.mockito.kotlin.mock
import org.mockito.kotlin.reset
import org.mockito.kotlin.verifyNoMoreInteractions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.malinskiy.marathon.execution.result

import com.malinskiy.marathon.execution.TestStatus
import com.nhaarman.mockitokotlin2.mock
import org.mockito.kotlin.mock
import org.junit.jupiter.api.Test
import com.malinskiy.marathon.test.Test as MarathonTest
import assertk.assertThat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import com.malinskiy.marathon.test.StubDevice
import com.malinskiy.marathon.test.assert.shouldBeEqualToAsJson
import com.malinskiy.marathon.test.setupMarathon
import com.malinskiy.marathon.time.Timer
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.advanceTimeBy
Expand All @@ -21,7 +20,6 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Test
import org.koin.core.context.stopKoin
import java.io.File
import java.util.concurrent.TimeUnit
import kotlin.time.ExperimentalTime
import com.malinskiy.marathon.test.Test as MarathonTest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import com.malinskiy.marathon.test.StubDevice
import com.malinskiy.marathon.test.assert.shouldBeEqualToAsJson
import com.malinskiy.marathon.test.setupMarathon
import com.malinskiy.marathon.time.Timer
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.advanceTimeBy
Expand All @@ -22,7 +21,6 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Test
import org.koin.core.context.stopKoin
import java.io.File
import java.util.concurrent.TimeUnit
import kotlin.time.ExperimentalTime
import com.malinskiy.marathon.test.Test as MarathonTest

Expand Down
Loading