0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-19 19:42:17 +02:00

refactor: shared "testlib" module, used by AnkiDroid test and androidTest

This commit is contained in:
Mike Hardy 2024-02-01 12:38:00 -05:00 committed by Brayan Oliveira
parent c8715ebd09
commit cf8cf278e4
6 changed files with 65 additions and 3 deletions

View File

@ -76,9 +76,9 @@ android {
// needed for upgrades to be offered correctly.
versionCode=21700117
versionName="2.17alpha17"
minSdk 23
minSdk 23 // also in testlib/build.gradle.kts
// After #13695: change .tests_emulator.yml
targetSdk 33 // change api/build.gradle.kts and update ../robolectricDownloader.gradle at same time
targetSdk 33 // also in [api|testlib]/build.gradle.kts and ../robolectricDownloader.gradle
testApplicationId "com.ichi2.anki.tests"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner 'com.ichi2.testutils.NewCollectionPathTestRunner'
@ -155,6 +155,8 @@ android {
* Product Flavors are used for Amazon App Store and Google Play Store.
* This is because we cannot use Camera Permissions in Amazon App Store (for FireTv etc...)
* Therefore, different AndroidManifest for Camera Permissions is used in Amazon flavor.
*
* This flavor block must stay in sync with the same block in testlib/build.gradle.kts
*/
flavorDimensions += "appStore"
productFlavors {
@ -369,6 +371,8 @@ dependencies {
// build via AnkiDroidApp.
implementation 'com.squareup.leakcanary:leakcanary-android:2.13'
testImplementation project(':testlib')
// A path for a testing library which provide Parameterized Test
testImplementation "org.junit.jupiter:junit-jupiter:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
@ -391,6 +395,9 @@ dependencies {
// in a JvmTest we need org.json.JSONObject to not be mocked
testImplementation 'org.json:json:20231013'
testImplementation 'io.github.ivanshafran:shared-preferences-mock:1.2.4'
androidTestImplementation project(':testlib')
// May need a resolution strategy for support libs to our versions
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
androidTestImplementation("androidx.test.espresso:espresso-contrib:$espresso_version") {

View File

@ -26,4 +26,4 @@ dependencyResolutionManagement {
}
}
include(":lint-rules", ":api", ":AnkiDroid")
include(":lint-rules", ":api", ":AnkiDroid", ":testlib")

1
testlib/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

52
testlib/build.gradle.kts Normal file
View File

@ -0,0 +1,52 @@
plugins {
id("com.android.library")
id("kotlin-android")
}
android {
namespace = "com.ichi2.anki.testlib"
compileSdk = 34
defaultConfig {
minSdk = 23
}
flavorDimensions += "appStore"
productFlavors {
create("play") {
dimension = "appStore"
}
create("amazon") {
dimension = "appStore"
}
// A 'full' build has no restrictions on storage/camera. Distributed on GitHub/F-Droid
create("full") {
dimension = "appStore"
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
}
packaging {
resources {
excludes += "META-INF/DEPENDENCIES"
}
}
}
}
dependencies {
implementation(project(":AnkiDroid"))
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core")
compileOnly("org.hamcrest:hamcrest:" + rootProject.ext["hamcrest_version"])
compileOnly("org.junit.jupiter:junit-jupiter:" + rootProject.ext["junit_version"])
compileOnly("org.junit.jupiter:junit-jupiter-params:" + rootProject.ext["junit_version"])
compileOnly("org.junit.vintage:junit-vintage-engine:" + rootProject.ext["junit_version"])
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />