Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Android library for generating instrumentation reports in Allure format

License

Notifications You must be signed in to change notification settings

allure-framework/allure-android

Repository files navigation

Build Status Download

[DEPRICATED]

Allurе-android isn't supported anymore. Please, use allure-kotlin instead. For migration on allure-kotlin, please follow the guide.

Allure Android

Allure adapter for Android, which is written on Kotlin.

Installation and Usage

Configure

Gradle

New version with support AndroidX, available here.

Add to: app/build.gradle

apply plugin: 'kotlin-android'

repositories {
    mavenCentral()
    maven { url 'https://dl.bintray.com/qameta/maven' }
}

dependencies {
    androidTestCompile "io.qameta.allure:allure-android-commons:2.0.0"
    androidTestCompile "io.qameta.allure:allure-android-model:2.0.0"
    androidTestCompile "io.qameta.allure:allure-espresso:2.0.0"

    androidTestCompile "org.jetbrains.kotlin:kotlin-stdlib:1.2.51"
    androidTestCompile "junit:junit:4.12"
    androidTestCompile "androidx.test.uiautomator:uiautomator:2.2.0"
}

android {
    defaultConfig {
        testInstrumentationRunner "io.qameta.allure.espresso.AllureAndroidRunner"
    }
}

But be aware that new version isn't backward compatible with older versions.

Old version, without AndroidX, now not supported Add to: app/build.gradle

apply plugin: 'kotlin-android'

dependencies {
    androidTestCompile "ru.tinkoff.allure:allure-android:2.5.1@aar"
    androidTestCompile "ru.tinkoff.allure:allure-common:2.5.1"
    androidTestCompile "ru.tinkoff.allure:allure-model:2.5.1"

    androidTestCompile "org.jetbrains.kotlin:kotlin-stdlib:1.1.51"
    androidTestCompile "junit:junit:4.12"
    androidTestCompile "com.android.support.test.uiautomator:uiautomator-v18:2.1.2"
}

android {
    defaultConfig {
        testInstrumentationRunner "ru.tinkoff.allure.android.AllureAndroidRunner"
    }
}

Pull allure results

Just use comandline tools from Android sdk:

adb pull /sdcard/allure-results

Generate allure report

You can use allure-commandline for that, see Allure Docs for details, or generate report with allure-gradle plugin.

Compatibility with Android 8.0+ (API 26 or higher)

Look at #12 (comment) for more information.

Features

Steps

Original Steps were improved:

  • No more aspects required, step is an expression
  • Name required, but not limited with const value as in annotations

You can use DSL-style steps anywhere in test method:

@Test
fun test() {
    step("First Step") {
        ...
    }
    step("Second Step") {
        ...
        myStep("Param") // Steps can be nested
    }
}

// Steps are expressions
fun myStep(param: String) = step("Do something with $param") {
    ...
}

Soft Assertions

Soft Assertion can be used to continue test execution in case of minor assertion. SoftAssert reports assertion inside Step in which it raised.

SoftAssert marks test passed, result could be found only in report

DSL-style:

fun myStep() = step("MyStep") {
    softly {
        checkThat("FirstAssert", true, IsEqual(false))
    }
}

Basic screenshot

Screenshot uses UIautomator and appends it to step, in which it was executed

@Test
fun test() {
    deviceScreenshot("screenshot_name")
}

Failshot rule

You can use FailshotRule to capture a screenshot in case of Throwable during test

class MyTest {

    @get:Rule
    val failshot = FailshotRule()

    // ...
}

Logcat rule's (only in new version)

You can use LogcatDumpRule, LogcatClearRule to clear and capture a device logs in case of Throwable during test

class MyTest {

    @get:Rule
    val ruleChain = RuleChain.outerRule(LogcatClearRule()).around(LogcatDumpRule())

    // ...
}

Window hierarchy rule (only in new version)

You can use WindowHierarchyRule to capture a window hierarchy via UIautomator in case of Throwable during test

class MyTest {

    @get:Rule
    val windowHierarchyRule = WindowHierarchyRule()

    // ...
}

Allure annotations

You can use some allure annotation, like @DisplayName, @Link, @Issue, @Owner(only in new version), @SeverityLevel(only in new version) and others.

Contributing to allure-android

Thanks to all people who contributed. Especially Tinkoff and @Badya who started and maintaining allure-android.

License

Allure Android is released under version 2.0 of the Apache License