Why not allure-android
? The Allure Android adapter implementation is limited and it doesn't support all of the features of Allure. Its drawbacks are following:
- no support for all annotations e.g.
@Description
,@LinkAnnotations
- limited API when comparing to
allure-java
- poor test coverage
- tight coupling with Android Instrumentation tests, so it can't be easily reused for unit tests or Robolectric tests
Due to the mentioned limitations allure-kotlin
was born as a core for different Kotlin and Android test frameworks.
This is a module used under the hood and shouldn't be accessed by consumers code. If you are using those classes, beware that some of them may have different nullability and mutability.
- Replace dependency
dependencies { //REMOVE allure-android dependency androidTestImplementation "io.qameta.allure:allure-android-model:$ALLURE_ANDROID_VERSION" //ADD allure-kotlin dependency androidTestImplementation "io.qameta.allure:allure-kotlin-model:$ALLURE_KOTLIN_VERSION" }
- Change all imports from
io.qameta.allure.android.model.*
->io.qameta.allure.kotlin.model.*
- Replace dependencies
dependencies { //REMOVE allure-android dependency androidTestImplementation "io.qameta.allure:allure-android-commons:$ALLURE_ANDROID_VERSION" //ADD allure-kotlin dependencies androidTestImplementation "io.qameta.allure:allure-kotlin-commons:$ALLURE_KOTLIN_VERSION" androidTestImplementation "io.qameta.allure:allure-kotlin-junit4:$ALLURE_KOTLIN_VERSION" }
- Migrate core classes
- Migrate global
step
function fromio.qameta.allure.android.step
toio.qameta.allure.kotlin.Allure#step
using the following example (the API is a bit different and allows for specifying parameters inside the lambda):Explore//allure-android definition step("Step1", Parameter("param1", "true"), Parameter("param2", "false")) { assertTrue(true) } ... //allure-kotlin definition Allure.step("Step 1") { parameter("param1", "true") parameter("param2", "false") assertTrue(true) }
Allure
API as it allows to define labels, epics and other allure components from the code, instead of only via annotations. - Migrate
AllureRunListener
fromio.qameta.allure.android.AllureRunListener
->io.qameta.allure.kotlin.junit4.AllureJunit4
- Migrate
AllureLifecycle
fromio.qameta.allure.android.AllureLifecycle
->io.qameta.allure.kotlin.AllureLifecycle
(which has a lot more capabilities and allows to attach lifecycle listeners) - Change import for
AllureRunner
fromio.qameta.allure.android.AllureRunner
->io.qameta.allure.kotlin.junit4.AllureRunner
- Migrate global
- Migrate package
annotations
- Change all imports from
io.qameta.allure.android.annotations.*
->io.qameta.allure.kotlin.*
(explore new annotations package as support for many more annotations has been added) - Change imports for Allure Junit4 annotations
DisplayName
,Tag
,Tags
fromio.qameta.allure.android.annotations.*
->io.qameta.allure.kotlin.junit4.*
- Change import for
SeverityLevel
fromio.qameta.allure.android.SeverityLevel
->io.qameta.allure.kotlin.SeverityLevel
- Change all imports from
- Migrate package
io
- Change all imports from
io.qameta.allure.android.io.*
->io.qameta.allure.kotlin.*
- In case you have custom
AllureResultsWriter
adjust it as the API has changed a bit AllureResultsReader
&FileSystemResultsReader
have been removed as they are not used anymore- In case you are using any of the constants like from
AllureFileConstants
(likeTEXT_PLAIN
,TXT_EXTENSION
) define them yourself as they are not part of public API anymore.
- Change all imports from
- Migrate package
listener
- change all imports fromio.qameta.allure.android.listener.*
->io.qameta.allure.kotlin.listener.*
- Migrate package
serialization
- it was used internally and is no longer needed. - Migrate package
utils
- it was used to parse the annotations to allure results. It shouldn't be accesed by consumer code. If you were using any of those methods take a look atio.qameta.allure.kotlin.util.ResultsUtils
for replacement (as the implementation of parsing annotations has changed).
- Replace dependency
dependencies { //REMOVE allure-android dependency androidTestImplementation "io.qameta.allure:allure-espresso:$ALLURE_ANDROID_VERSION" //ADD allure-kotlin dependency androidTestImplementation "io.qameta.allure:allure-kotlin-android:$ALLURE_KOTLIN_VERSION" }
- Migrate runners (don't forget migrating
testInstrumentationRunner
gradle configuration)- Change import for
AllureAndroidRunner
fromio.qameta.allure.espresso.AllureAndroidRunner
->io.qameta.allure.android.runners.AllureAndroidJUnitRunner
- Change import for
MultiDexAllureAndroidRunner
fromio.qameta.allure.espresso.MultiDexAllureAndroidRunner
->io.qameta.allure.android.runners.MultiDexAllureAndroidJUnitRunner
- Change import for
- Replace
AllureAndroidListener
usages withio.qameta.allure.kotlin.junit4.AllureJunit4
. In case you want to have external storage permissions automatically granted as well (default behaviour ofAllureAndroidListener
) attach addititional test listenerio.qameta.allure.android.listeners.ExternalStoragePermissionsListener
- Migrate test rules
- Replace
FailshotRule
withio.qameta.allure.android.rules.ScreenshotRule
that includes configuration to take a screenshot after sucessfull tests. - Replace
LogcatClearRule
&LogcatDumpRule
withio.qameta.allure.android.rules.LogcatRule
that merges behaviour of those 2 rules. - Change import for
WindowHierarchyRule
toio.qameta.allure.android.rules.WindowHierarchyRule
- Replace
- Change import for
AllureAndroidLifecycle
fromio.qameta.allure.espresso.io.qameta.allure.espresso
->io.qameta.allure.android.AllureAndroidLifecycle
- Migrate
addAttachment
/prepareAttachment
methods as the signature changed (renamed & reordered parameters, fixed nullability). Most importantly thefile
parameter type was changed fromFile
to eitherByteArray
orInputStream
. The easiest way to migrate it is to convert thefile
toInputStream
(e.g.FileInputStream(file)
). - Where possible migrate
addAttachment
toAllure.attachment
as this is the API that should be used for updating allure results.
- Migrate
- Change import for
LogCatListener
fromio.qameta.allure.espresso.listener.LogCatListener
->io.qameta.allure.android.listeners.LogcatListener
- Migrate screenshots taking from
deviceScreenshot
toio.qameta.allure.android.allureScreenshot
that allows to specify quality and scale of a screenshot.