在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):allure-framework/allure-kotlin开源软件地址(OpenSource Url):https://github.com/allure-framework/allure-kotlin开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):Allure Kotlin IntegrationsThe repository contains Allure2 adaptors for JVM-based test frameworks targeting Kotlin and Java with 1.6 source compatibility. The core of this library was ported from Check out the Allure Documentation. Supported frameworks
Getting startedJUnit4Setting up the dependencyrepositories {
mavenCentral()
}
dependencies {
testImplementation "io.qameta.allure:allure-kotlin-model:$LATEST_VERSION"
testImplementation "io.qameta.allure:allure-kotlin-commons:$LATEST_VERSION"
testImplementation "io.qameta.allure:allure-kotlin-junit4:$LATEST_VERSION"
} Attaching listenerAttach the
@RunWith(AllureRunner::class)
class MyTest {
...
}
@RunWith(AllureParametrizedRunner::class)
class MyParameterizedTest {
...
} Android testsSetting up the dependencyrepositories {
mavenCentral()
}
dependencies {
androidTestImplementation "io.qameta.allure:allure-kotlin-model:$LATEST_VERSION"
androidTestImplementation "io.qameta.allure:allure-kotlin-commons:$LATEST_VERSION"
androidTestImplementation "io.qameta.allure:allure-kotlin-junit4:$LATEST_VERSION"
androidTestImplementation "io.qameta.allure:allure-kotlin-android:$LATEST_VERSION"
} Attaching listenerAndroidX Test introduced a new @RunWith(AllureAndroidJUnit4::class)
class MyInstrumentationTest {
...
} Using AllureAndroidJUnit4 over class - works for both robolectric and on-device tests. Robolectric testsRobolectric tests are simple unit tests, hence the API is the same. The report data will be placed in the same place as for unit tests. On-device instrumentation testsYou can also use testInstrumentationRunner for setting up runner.
IntegrationAs on-device instrumentation test run on an actual device, the results have to be saved there as well.
You don't need to add any permissions to manifest: results are saved in an app files directory, e.g.
After the tests are finished you can move the results to the external storage and pull the files using an adb like this one:
Finally, you can generate the report via Allure CLI (see the Allure Documentation) or generate report with allure-gradle plugin. Orchestrator TestStorageWhen tests clears app data between each tests then saving test results in app storage will not work because old test results will be cleared when app data is cleared. To save test results directly on sdcard new TestStorage from androidx.test.services can be used. Enabling test storage for automation tests:
After that allure will use TestStorage to save test results. Test results will be saved by default into NOTE: allure-results folder name can be changed using FeaturesThe Allure Android API includes couple of features to make your reports a bit better. Screenshot attachmentScreenshot can be taken and appended as an attachment to step or test in which they were executed: @Test
fun screenshotExample() {
step("Step screenshot") {
allureScreenshot(name = "ss_step", quality = 90, scale = 1.0f)
}
allureScreenshot(name = "ss_test", quality = 50, scale = 1.0f)
} Screenshot ruleTest rule to make the screenshot after each test and attach it to the test report. It includes a
@get:Rule
val logcatRule = ScreenshotRule(mode = ScreenshotRule.Mode.END, screenshotName = "ss_end") Logcat ruleTest rule that clears the logcat before each test and appends the log dump as an attachment in case of failure. @get:Rule
val logcatRule = LogcatRule() Window hierarchy ruleYou can use WindowHierarchyRule to capture a window hierarchy via uiautomator in case of Throwable during test. @get:Rule
val windowHierarchyRule = WindowHierarchyRule() SamplesDifferent examples of
Connection with allure-javaFollowing modules have been migrated:
Following changes have to be made in order to keep the compatibility with Java 1.6:
The only part that was not migrated is aspects support. ContributingThanks to all people who contributed. Especially @kamildziadek who started allure-kotlin. Contribute. LicenseThe Allure Framework is released under version 2.0 of the Apache License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论