-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Customise allure results directory * 2.3.4
- Loading branch information
1 parent
44f5788
commit d37e965
Showing
7 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
ultron-allure/src/main/java/com/atiurin/ultron/allure/attachment/AllureDirectoryUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.atiurin.ultron.allure.attachment | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import io.qameta.allure.kotlin.util.PropertiesUtils | ||
import java.io.File | ||
|
||
object AllureDirectoryUtil { | ||
|
||
fun getResultsDirectoryName(): String = PropertiesUtils.resultsDirectoryPath | ||
|
||
/** | ||
* From Allure source code | ||
* see [https://github.com/allure-framework/allure-kotlin/blob/master/allure-kotlin-android/src/main/kotlin/io/qameta/allure/android/AllureAndroidLifecycle.kt] | ||
*/ | ||
fun getOriginalResultsDirectory(): File { | ||
return File(InstrumentationRegistry.getInstrumentation().targetContext.filesDir, getResultsDirectoryName()) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
ultron-allure/src/main/java/com/atiurin/ultron/allure/config/AllureConfigParams.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ure/src/main/java/com/atiurin/ultron/allure/runner/UltronAllureResultsTransferListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.atiurin.ultron.allure.runner | ||
|
||
import com.atiurin.ultron.extensions.createDirectoryIfNotExists | ||
import com.atiurin.ultron.log.UltronLog | ||
import com.atiurin.ultron.runner.UltronRunListener | ||
import org.junit.runner.Result | ||
import java.io.File | ||
import kotlin.system.measureTimeMillis | ||
|
||
/** | ||
* Transfer files from original Allure results directory [sourceDir] | ||
* to custom directory [targetDir] provided by user [UltronAllureConfig.setAllureResultsDirectory] | ||
*/ | ||
class UltronAllureResultsTransferListener(private val sourceDir: File, private val targetDir: File) : UltronRunListener() { | ||
override fun testRunFinished(result: Result) { | ||
UltronLog.info("Copy Allure results from '${sourceDir.absolutePath}' to '${targetDir.absolutePath}'") | ||
targetDir.createDirectoryIfNotExists() | ||
var isSuccessfullyCopied = true | ||
val time = measureTimeMillis { | ||
sourceDir.copyRecursively(targetDir, true, onError = { file, ioException -> | ||
UltronLog.error(""" | ||
|Unable to copy Allure results file '${file.absolutePath}' to '${targetDir.absolutePath}'. | ||
|Got exception : '${ioException.message}'. | ||
|Source directory '${sourceDir.absolutePath}' won't be deleted. | ||
""".trimMargin() | ||
) | ||
isSuccessfullyCopied = false | ||
OnErrorAction.SKIP | ||
}) | ||
if (isSuccessfullyCopied) sourceDir.deleteRecursively() | ||
} | ||
UltronLog.info("Allure results files transfer time = $time ms") | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters