From 86d0f3e6992b08139ded5edfc5738009698cc8f5 Mon Sep 17 00:00:00 2001 From: Kamil Dziadek Date: Sun, 28 Jun 2020 22:25:39 +0200 Subject: [PATCH 01/12] Setting up android sample * setting up new sample module * filtering out the samples from generic configuration * adding configuration for running the same test on device and using robolectric * adding `SampleActivity.kt` with a simple button and label * adding `SampleCalculator.kt` that will serve the purpose of unit testing --- build.gradle.kts | 3 +- samples/junit4-android/build.gradle.kts | 54 ++++++ samples/junit4-android/proguard-rules.pro | 0 .../src/main/AndroidManifest.xml | 19 ++ .../sample/junit4/android/SampleActivity.kt | 19 ++ .../sample/junit4/android/SampleCalculator.kt | 6 + .../drawable-v24/ic_launcher_foreground.xml | 34 ++++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++++ .../src/main/res/layout/activity_sample.xml | 22 +++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 2963 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2060 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4490 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6387 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9128 bytes .../src/main/res/values/strings.xml | 6 + .../src/main/res/values/styles.xml | 13 ++ settings.gradle.kts | 3 +- 18 files changed, 352 insertions(+), 2 deletions(-) create mode 100644 samples/junit4-android/build.gradle.kts create mode 100644 samples/junit4-android/proguard-rules.pro create mode 100644 samples/junit4-android/src/main/AndroidManifest.xml create mode 100644 samples/junit4-android/src/main/java/io/qameta/allure/sample/junit4/android/SampleActivity.kt create mode 100644 samples/junit4-android/src/main/java/io/qameta/allure/sample/junit4/android/SampleCalculator.kt create mode 100644 samples/junit4-android/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 samples/junit4-android/src/main/res/drawable/ic_launcher_background.xml create mode 100644 samples/junit4-android/src/main/res/layout/activity_sample.xml create mode 100644 samples/junit4-android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 samples/junit4-android/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 samples/junit4-android/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 samples/junit4-android/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 samples/junit4-android/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 samples/junit4-android/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 samples/junit4-android/src/main/res/values/strings.xml create mode 100644 samples/junit4-android/src/main/res/values/styles.xml diff --git a/build.gradle.kts b/build.gradle.kts index 649fc0f..45544e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,8 @@ allprojects { val gradleScriptDir by extra("${rootProject.projectDir}/gradle") configure(subprojects - .filter { !it.name.contains("android") } + .filter { !it.name.contains("android") } + .filter { it.parent?.name != "samples" } ) { apply(plugin = "org.jetbrains.kotlin.jvm") apply(from = "$gradleScriptDir/maven-publish.gradle") diff --git a/samples/junit4-android/build.gradle.kts b/samples/junit4-android/build.gradle.kts new file mode 100644 index 0000000..b2af226 --- /dev/null +++ b/samples/junit4-android/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("kotlin-android") +} + +android { + compileSdkVersion(Versions.Android.compileSdk) + defaultConfig { + applicationId = "io.qameta.allure.sample.junit4.android" + minSdkVersion(Versions.Android.minSdk) + targetSdkVersion(Versions.Android.targetSdk) + versionCode = 1 + versionName = version as String + + testInstrumentationRunner = "io.qameta.allure.android.runners.AllureAndroidJUnitRunner" + testInstrumentationRunnerArguments(mapOf("clearPackageData" to "true")) + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + sourceSets { + val sharedTestDir = "src/sharedTest/java" + getByName("test").java.srcDir(sharedTestDir) + getByName("androidTest").java.srcDir(sharedTestDir) + } + + testOptions.unitTests.isIncludeAndroidResources = true +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + implementation(kotlin("stdlib-jdk7", Versions.kotlin)) + + implementation("androidx.appcompat:appcompat:${Versions.Android.androidX}") + implementation("androidx.core:core-ktx:${Versions.Android.androidX}") + + listOf( + project(":allure-kotlin-android"), + "androidx.test.ext:junit:${Versions.Android.Test.junit}", + "androidx.test:runner:${Versions.Android.Test.runner}", + "junit:junit:${Versions.junit4}", + "androidx.test.espresso:espresso-core:${Versions.Android.Test.espresso}" + ).forEach { + testImplementation(it) + androidTestImplementation(it) + } + + testImplementation("org.robolectric:robolectric:${Versions.Android.Test.robolectric}") +} diff --git a/samples/junit4-android/proguard-rules.pro b/samples/junit4-android/proguard-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/samples/junit4-android/src/main/AndroidManifest.xml b/samples/junit4-android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..3de8d84 --- /dev/null +++ b/samples/junit4-android/src/main/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/junit4-android/src/main/java/io/qameta/allure/sample/junit4/android/SampleActivity.kt b/samples/junit4-android/src/main/java/io/qameta/allure/sample/junit4/android/SampleActivity.kt new file mode 100644 index 0000000..936e71b --- /dev/null +++ b/samples/junit4-android/src/main/java/io/qameta/allure/sample/junit4/android/SampleActivity.kt @@ -0,0 +1,19 @@ +package io.qameta.allure.sample.junit4.android + +import android.os.Bundle +import android.widget.Button +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity + +class SampleActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_sample) + + findViewById