Skip to content

Commit

Permalink
Merge pull request #873 from MarathonLabs/feature/raw_json_meta
Browse files Browse the repository at this point in the history
feat(raw_json_meta): meta properties like test annotations were added…
  • Loading branch information
Malinskiy authored Dec 7, 2023
2 parents b06461a + 9098656 commit 0106217
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ class RawJsonReporter(

override fun generate(executionReport: ExecutionReport) {
val testResults = executionReport.testEvents.map {
val metaPropertiesList = it.testResult.test.metaProperties.map { metaProp ->
val valuesAsStringMap = metaProp.values.mapValues { (_, value) ->
value?.toString() ?: ""
}
StringMetaProperty(
name = metaProp.name,
values = valuesAsStringMap
)
}

RawTestRun(
it.testResult.test.pkg,
it.testResult.test.clazz,
it.testResult.test.method,
metaPropertiesList,
it.device.serialNumber,
it.testResult.status,
it.testResult.isIgnored,
Expand All @@ -35,11 +46,17 @@ class RawJsonReporter(
@SerializedName("package") val pkg: String,
@SerializedName("class") val clazz: String,
@SerializedName("method") val method: String,
@SerializedName("metaProperties") val metaProperties: List<StringMetaProperty>,
@SerializedName("deviceSerial") val deviceSerial: String,
@SerializedName("status") val status: TestStatus,
@SerializedName("ignored") val ignored: Boolean,
@SerializedName("success") val success: Boolean,
@SerializedName("timestamp") val timestamp: Long,
@SerializedName("duration") val duration: Long
)

data class StringMetaProperty(
@SerializedName("name") val name: String,
@SerializedName("values") val values: Map<String, String> = emptyMap()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ package com.malinskiy.marathon.scenario

import com.malinskiy.marathon.device.DeviceProvider
import com.malinskiy.marathon.execution.TestStatus
import com.malinskiy.marathon.test.MetaProperty
import com.malinskiy.marathon.test.StubDevice
import com.malinskiy.marathon.test.assert.shouldBeEqualToAsJson
import com.malinskiy.marathon.test.setupMarathon
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.advanceTimeBy
Expand All @@ -18,7 +18,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 All @@ -33,7 +32,17 @@ class SuccessScenariosTest {
var output: File? = null

val marathon = setupMarathon {
val test = MarathonTest("test", "SimpleTest", "test", emptySet())
val test = MarathonTest(
"test",
"SimpleTest",
"test",
listOf(
MetaProperty(
name = "someAnnotation",
values = mapOf("value" to "someValue")
)
)
)
val device = StubDevice()

configuration {
Expand Down
10 changes: 9 additions & 1 deletion core/src/test/resources/output/raw/success_scenario_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
"package": "test",
"class": "SimpleTest",
"method": "test",
"metaProperties": [
{
"name": "someAnnotation",
"values": {
"value": "someValue"
}
}
],
"deviceSerial": "serial-1",
"status": "PASSED",
"ignored": false,
"success": true,
"timestamp": 0,
"duration": 1
}
]
]

0 comments on commit 0106217

Please sign in to comment.