Skip to content

Commit

Permalink
Update Allure, remove allure-environment-writer, try to fix attachmen…
Browse files Browse the repository at this point in the history
…ts import to Allure TestOps from AllureReporter
  • Loading branch information
Ivan Dyatlov committed Dec 18, 2024
1 parent 96d43cf commit d636061
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
1 change: 0 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies {
implementation(project(":report:execution-timeline"))

implementation(libs.allure.java.commons)
implementation(libs.allure.environment.writer)
implementation(libs.apache.commons.collections)
implementation(libs.apache.commons.io)
implementation(libs.apache.commons.text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.malinskiy.marathon.report.allure

import com.github.automatedowl.tools.AllureEnvironmentWriter.allureEnvironmentWriter
import com.google.common.collect.ImmutableMap
import com.malinskiy.marathon.analytics.internal.sub.ExecutionReport
import com.malinskiy.marathon.device.DeviceInfo
import com.malinskiy.marathon.execution.Configuration
Expand Down Expand Up @@ -32,6 +30,7 @@ import io.qameta.allure.model.StatusDetails
import io.qameta.allure.util.ResultsUtils
import java.io.File
import java.io.FileOutputStream
import java.nio.file.Files
import java.util.Properties
import java.util.UUID

Expand All @@ -56,16 +55,12 @@ class AllureReporter(
lifecycle.writeTestCase(uuid)
}

val params = configuration.toMap()
val builder = ImmutableMap.builder<String, String>()
val params = configuration.toMap().toMutableMap()
params.forEach {
builder.put(it.key, it.value)
params[it.key] = it.value
}
builder.put("platform", "Android")

val environment = builder.build()
allureEnvironmentWriter(environment, outputDirectory.absolutePath + File.separator)
environment.saveToEnvironmentProperties()
params["platform"] = "Android"
params.saveToEnvironmentProperties()
}

private fun Map<String, String>.saveToEnvironmentProperties() {
Expand Down Expand Up @@ -111,12 +106,18 @@ class AllureReporter(
.setSource(summaryFile.relativePathTo(outputDirectory))
.setType("text/plain")

testResult.attachments.forEach {
val linkFile = outputDirectory.resolve(it.file.name).toPath()
Files.deleteIfExists(linkFile)
Files.createSymbolicLink(linkFile, it.file.toPath())
}

val testAttachments: List<Attachment> = testResult
.attachments
.map {
Attachment()
.setName(it.type.name.lowercase().replaceFirstChar(Char::titlecase))
.setSource(it.file.relativePathTo(outputDirectory))
.setSource(it.file.name)
.setType(it.type.toMimeType())
}

Expand Down Expand Up @@ -155,6 +156,7 @@ class AllureReporter(
test.findValue<String>(TmsLink::class.java.canonicalName)?.let { allureTestResult.links.add(ResultsUtils.createTmsLink(it)) }
allureTestResult.labels.add(ResultsUtils.createLabel("layer", "UI"))
allureTestResult.labels.add(ResultsUtils.createLabel("platform", "Android"))
allureTestResult.labels.addAll(ResultsUtils.getProvidedLabels())
allureTestResult.labels.addAll(test.getOptionalLabels())

return allureTestResult
Expand All @@ -173,7 +175,9 @@ class AllureReporter(
findValue<String>(Owner::class.java.canonicalName)?.let { list.add(ResultsUtils.createOwnerLabel(it)) }
findValue<String>(Lead::class.java.canonicalName)?.let { list.add(ResultsUtils.createLabel(ResultsUtils.LEAD_LABEL_NAME, it)) }
findValue<String>("io.qameta.allure.junit4.Tag")?.let { list.add(ResultsUtils.createTagLabel(it)) }
findValue<String>("io.qameta.allure.Layer")?.let { list.add(ResultsUtils.createLabel("layer", it)) }
findValue<String>("io.qameta.allure.label.Layer")?.let { list.add(ResultsUtils.createLabel("layer", it)) }
findValue<String>("io.qameta.allure.label.Team")?.let { list.add(ResultsUtils.createLabel("team", it)) }
findValue<String>("io.qameta.allure.label.Component")?.let { list.add(ResultsUtils.createLabel("component", it)) }

return list
}
Expand Down
4 changes: 1 addition & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[versions]
allure-java = "2.28.0"
allure-environment-writer = "1.0.0"
allure-java = "2.29.1"
android-gradle-plugin = "8.7.3"
android-tools = "31.7.3"
apache-commons-collections = "4.4"
Expand All @@ -26,7 +25,6 @@ testcontainers = "1.15.3"

[libraries]
allure-java-commons = { module = "io.qameta.allure:allure-java-commons", version.ref = "allure-java" }
allure-environment-writer = { module = "com.github.automatedowl:allure-environment-writer", version.ref = "allure-environment-writer" }
android-gradle-api = { module = "com.android.tools.build:gradle-api", version.ref = "android-gradle-plugin" }
android-tools-common = { module = "com.android.tools:common", version.ref = "android-tools" }
android-tools-ddmlib = { module = "com.android.tools.ddms:ddmlib", version.ref = "android-tools" }
Expand Down

0 comments on commit d636061

Please sign in to comment.