This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from TinkoffCreditSystems/v2.5.1
version 2.5.1.
- Loading branch information
Showing
43 changed files
with
690 additions
and
379 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<lint> | ||
<issue id="AllowBackup" severity="ignore"/> | ||
<issue id="InvalidPackage" severity="ignore"/> | ||
<issue id="AllowBackup" severity="ignore"/> | ||
<issue id="InvalidPackage" severity="ignore"/> | ||
<issue id="GradleDependency" severity="informational"/> | ||
</lint> |
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 |
---|---|---|
@@ -1,44 +1,79 @@ | ||
apply plugin: "com.android.library" | ||
apply plugin: "kotlin-android" | ||
|
||
dependencies { | ||
compile project(":allure-model") | ||
compile project(":allure-common") | ||
compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}" | ||
compile "com.android.support:support-annotations:${supportVersion}" | ||
compile "com.android.support.test:runner:${supportTestVersion}" | ||
compile "com.android.support:multidex:${multidexVersion}" | ||
compile "com.android.support.test.uiautomator:uiautomator-v18:${uiAutomatorVersion}" | ||
compile "junit:junit:${jUnitVersion}" | ||
buildscript { | ||
apply from: '../gradle/versions.gradle' | ||
apply from: '../gradle/common.gradle' | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath "com.android.tools.build:gradle:${androidPlugin}" | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}" | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion rootProject.compileSdkVersion | ||
buildToolsVersion rootProject.buildToolsVersion | ||
|
||
defaultConfig { | ||
targetSdkVersion rootProject.compileSdkVersion | ||
minSdkVersion rootProject.minSdkVersion | ||
versionName rootProject.version | ||
versionName rootProject.projectVersion | ||
|
||
testInstrumentationRunner "ru.tinkoff.allure.android.AllureAndroidRunner" | ||
} | ||
|
||
lintOptions { | ||
htmlReport true | ||
abortOnError true | ||
warningsAsErrors true | ||
htmlReport false | ||
abortOnError false | ||
warningsAsErrors false | ||
lintConfig file("${project.name}-lint.xml") | ||
} | ||
|
||
packagingOptions { | ||
exclude "LICENSE.txt" | ||
exclude "META-INF/LICENSE.txt" | ||
exclude "META-INF/NOTICE.txt" | ||
exclude 'LICENSE.txt' | ||
exclude 'META-INF/LICENSE.txt' | ||
exclude 'META-INF/NOTICE.txt' | ||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += "src/main/kotlin" | ||
androidTest.java.srcDirs += "src/androidTest/kotlin" | ||
main.java.srcDirs += 'src/main/kotlin' | ||
espresso.java.srcDirs += 'src/espresso/kotlin' | ||
androidTest.java.srcDirs += 'src/androidTest/kotlin' | ||
} | ||
|
||
testBuildType 'espresso' | ||
buildTypes { | ||
espresso { | ||
initWith debug | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':allure-model') | ||
implementation project(':allure-common') | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}" | ||
implementation "com.android.support:support-annotations:${supportVersion}" | ||
implementation "com.android.support.test:runner:${supportTestVersion}" | ||
implementation "com.android.support.test:rules:${supportTestVersion}" | ||
implementation "com.android.support:multidex:${multidexVersion}" | ||
implementation "com.android.support.test.uiautomator:uiautomator-v18:${uiAutomatorVersion}" | ||
implementation "junit:junit:${jUnitVersion}" | ||
|
||
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVersion}" | ||
androidTestImplementation "com.android.support.test.espresso:espresso-core:${espressoVersion}" | ||
|
||
espressoImplementation "com.android.support:appcompat-v7:${supportVersion}" | ||
espressoImplementation "com.android.support.constraint:constraint-layout:1.0.2" | ||
espressoImplementation "io.reactivex:rxjava:1.3.4" | ||
} | ||
|
||
task copyLibs(type: Copy) { | ||
from configurations.compile | ||
from configurations.testCompile | ||
into 'libs' | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:tools="http://schemas.android.com/tools" | ||
package="ru.tinkoff.allure"> | ||
|
||
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18" /> | ||
|
||
</manifest> |
32 changes: 32 additions & 0 deletions
32
allure-android/src/androidTest/kotlin/ru/tinkoff/allure/android/CrashTest.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,32 @@ | ||
package ru.tinkoff.allure | ||
|
||
import android.content.Intent | ||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.espresso.Espresso.onView | ||
import android.support.test.espresso.action.ViewActions.click | ||
import android.support.test.espresso.matcher.ViewMatchers.withId | ||
import android.support.test.rule.ActivityTestRule | ||
import android.support.test.runner.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class CrashTest { | ||
@get:Rule | ||
val activityRule = ActivityTestRule<CrashTestActivity>(CrashTestActivity::class.java, true, false) | ||
|
||
// adb shell am instrument -w -r -e debug false -e class ru.tinkoff.allure.CrashTest#crash ru.tinkoff.allure.test/ru.tinkoff.allure.android.AllureAndroidRunner | ||
@Test | ||
fun crash() { | ||
activityRule.launchActivity(Intent(InstrumentationRegistry.getTargetContext().applicationContext, CrashTestActivity::class.java)) | ||
onView(withId(R.id.crash_button)).perform(click()) | ||
} | ||
|
||
// adb shell am instrument -w -r -e debug false -e class ru.tinkoff.allure.CrashTest#rxCrash ru.tinkoff.allure.test/ru.tinkoff.allure.android.AllureAndroidRunner | ||
@Test | ||
fun rxCrash() { | ||
activityRule.launchActivity(Intent(InstrumentationRegistry.getTargetContext().applicationContext, CrashTestActivity::class.java)) | ||
onView(withId(R.id.rx_crash_button)).perform(click()) | ||
} | ||
} |
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,9 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
> | ||
|
||
<application | ||
android:theme="@style/Theme.AppCompat.DayNight"> | ||
<activity android:name="ru.tinkoff.allure.CrashTestActivity"> | ||
</activity> | ||
</application> | ||
</manifest> |
36 changes: 36 additions & 0 deletions
36
allure-android/src/espresso/kotlin/ru/tinkoff/allure/CrashTestActivity.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,36 @@ | ||
package ru.tinkoff.allure | ||
|
||
import android.os.Bundle | ||
import android.support.v7.app.AppCompatActivity | ||
import android.widget.Button | ||
import rx.Observable | ||
import rx.schedulers.Schedulers | ||
|
||
class CrashTestActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_test) | ||
|
||
findViewById<Button>(R.id.crash_button).setOnClickListener { | ||
stackOverflow() | ||
} | ||
|
||
findViewById<Button>(R.id.rx_crash_button).setOnClickListener { | ||
rxCrash() | ||
} | ||
} | ||
|
||
private fun stackOverflow() { | ||
stackOverflow() | ||
} | ||
|
||
private fun rxCrash() { | ||
Observable.error<RuntimeException>(RuntimeException()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe( | ||
/* onNext */ {}, | ||
/* onError */ {t:Throwable -> throw RuntimeException(t)}, | ||
/* onCompleted */ {}) | ||
} | ||
} |
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,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="ru.tinkoff.allure.CrashTestActivity"> | ||
|
||
<Button | ||
android:id="@+id/crash_button" | ||
android:layout_width="120dp" | ||
android:layout_height="120dp" | ||
android:text="@string/crash" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.265" | ||
tools:layout_constraintBottom_creator="1" | ||
tools:layout_constraintLeft_creator="1" | ||
tools:layout_constraintRight_creator="1" | ||
tools:layout_constraintTop_creator="1" /> | ||
|
||
<Button | ||
android:id="@+id/rx_crash_button" | ||
android:layout_width="120dp" | ||
android:layout_height="120dp" | ||
android:text="@string/rx_crash" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/crash_button" | ||
tools:layout_constraintBottom_creator="1" | ||
tools:layout_constraintLeft_creator="1" | ||
tools:layout_constraintRight_creator="1" | ||
tools:layout_constraintTop_creator="1" /> | ||
</android.support.constraint.ConstraintLayout> |
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,4 @@ | ||
<resources> | ||
<string name="crash">CRASH</string> | ||
<string name="rx_crash">RX CRASH</string> | ||
</resources> |
65 changes: 50 additions & 15 deletions
65
allure-android/src/main/kotlin/ru/tinkoff/allure/android/AllureAndroidListener.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 |
---|---|---|
@@ -1,35 +1,70 @@ | ||
package ru.tinkoff.allure.android | ||
|
||
import android.support.annotation.Keep | ||
import android.support.test.InstrumentationRegistry.getInstrumentation | ||
import android.support.test.internal.runner.listener.InstrumentationRunListener | ||
import android.support.test.uiautomator.UiDevice | ||
import org.junit.runner.Description | ||
import org.junit.runner.Result | ||
import ru.tinkoff.allure.AllureLifecycle | ||
import org.junit.runner.notification.Failure | ||
import ru.tinkoff.allure.AllureRunListener | ||
import ru.tinkoff.allure.model.Status | ||
import ru.tinkoff.allure.model.StatusDetails | ||
|
||
/** | ||
* @author Badya on 05.06.2017. | ||
*/ | ||
class AllureAndroidListener : InstrumentationRunListener() { | ||
private val lifecycle = AllureAndroidLifecycle | ||
private val allureListenerDelegate = AllureRunListener(lifecycle) | ||
|
||
@Keep | ||
class AllureAndroidListener : AllureRunListener() { | ||
override val lifecycle: AllureLifecycle | ||
get() = AllureAndroidLifecycle | ||
override fun testStarted(description: Description) { | ||
allureListenerDelegate.testStarted(description) | ||
} | ||
|
||
override fun testFinished(description: Description) { | ||
allureListenerDelegate.testFinished(description) | ||
} | ||
|
||
override fun testFailure(failure: Failure) { | ||
if (failure.description.isTest) { | ||
val uuid = "${failure.description.className}#${failure.description.methodName}" | ||
testFailed(uuid, failure) | ||
} else { | ||
suiteFailed(failure) | ||
} | ||
} | ||
|
||
override fun testRunStarted(description: Description) { | ||
override fun testRunStarted(description: Description?) { | ||
grantPermissions() | ||
super.testRunStarted() | ||
allureListenerDelegate.testRunStarted() | ||
} | ||
|
||
override fun testRunFinished(result: Result?) { | ||
allureListenerDelegate.testRunFinished() | ||
} | ||
|
||
private fun testFailed(uuid: String, failure: Failure) { | ||
with(lifecycle) { | ||
updateTestCase(uuid) { | ||
status = Status.fromThrowable(failure.exception) | ||
statusDetails = StatusDetails.fromThrowable(failure.exception) | ||
} | ||
writeTestCase(uuid) | ||
} | ||
} | ||
|
||
override fun testRunFinished(result: Result) { | ||
super.testRunFinished() | ||
private fun suiteFailed(failure: Failure) { | ||
failure.description.children.forEach { | ||
val uuid = "${it.className}#${it.methodName}" | ||
testFailed(uuid, failure) | ||
} | ||
} | ||
|
||
private fun grantPermissions() { | ||
UiDevice.getInstance(getInstrumentation()).executeShellCommand("pm grant " + getInstrumentation().context.packageName + " android.permission.WRITE_EXTERNAL_STORAGE") | ||
UiDevice.getInstance(getInstrumentation()).executeShellCommand("pm grant " + getInstrumentation().targetContext.packageName + " android.permission.WRITE_EXTERNAL_STORAGE") | ||
UiDevice.getInstance(getInstrumentation()).executeShellCommand("pm grant " + getInstrumentation().context.packageName + " android.permission.READ_EXTERNAL_STORAGE") | ||
UiDevice.getInstance(getInstrumentation()).executeShellCommand("pm grant " + getInstrumentation().targetContext.packageName + " android.permission.READ_EXTERNAL_STORAGE") | ||
with(UiDevice.getInstance(instrumentation)) { | ||
executeShellCommand("pm grant " + instrumentation.context.packageName + " android.permission.WRITE_EXTERNAL_STORAGE") | ||
executeShellCommand("pm grant " + instrumentation.targetContext.packageName + " android.permission.WRITE_EXTERNAL_STORAGE") | ||
executeShellCommand("pm grant " + instrumentation.context.packageName + " android.permission.READ_EXTERNAL_STORAGE") | ||
executeShellCommand("pm grant " + instrumentation.targetContext.packageName + " android.permission.READ_EXTERNAL_STORAGE") | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
allure-android/src/main/kotlin/ru/tinkoff/allure/android/AllureRunner.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,21 @@ | ||
package ru.tinkoff.allure.android | ||
|
||
import android.support.test.internal.runner.junit4.AndroidJUnit4ClassRunner | ||
import android.support.test.internal.util.AndroidRunnerParams | ||
import org.junit.runner.notification.RunNotifier | ||
import org.junit.runners.model.InitializationError | ||
|
||
/** | ||
* @author b.mukvich on 05.06.2017. | ||
*/ | ||
class AllureRunner | ||
/** | ||
* Constructs a new instance of the default runner | ||
*/ | ||
@Throws(InitializationError::class) | ||
constructor(klass: Class<*>, runnerParams: AndroidRunnerParams) : AndroidJUnit4ClassRunner(klass, runnerParams) { | ||
override fun run(notifier: RunNotifier?) { | ||
|
||
super.run(notifier) | ||
} | ||
} |
Oops, something went wrong.