-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prototyping com.android.test module and shared tests in a com.android…
….lib module. (#76) * Prototyping com.android.test module and shared tests in a com.android.lib module. * Bumped dependency guard version * Gradle 8.6 update * Using test-host and test-suite naming * Fixes CI checks * Fixing CI * android tests passed locally, but not on CI, not worring about it for now.
- Loading branch information
1 parent
11d6971
commit cec6e0d
Showing
19 changed files
with
897 additions
and
524 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
plugins { | ||
id 'com.android.test' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
compileSdk = Integer.parseInt(libs.versions.android.compile.sdk.get()) | ||
|
||
defaultConfig { | ||
minSdkVersion Integer.parseInt(libs.versions.android.min.sdk.get()) | ||
targetSdkVersion Integer.parseInt(libs.versions.android.target.sdk.get()) | ||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' | ||
} | ||
|
||
namespace = "com.handstandsam.shoppingapp.android.tests" | ||
|
||
targetProjectPath = ":app" | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly(project(":app")) | ||
|
||
implementation libs.androidx.espresso | ||
implementation libs.androidx.espresso.contrib | ||
implementation libs.androidx.test.rules | ||
implementation libs.androidx.testrunner | ||
implementation(project(":app-test-suite")) | ||
} |
34 changes: 34 additions & 0 deletions
34
app-test-host/src/main/java/com/handstandsam/shoppingapp/tests/AndroidTestModuleTest.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,34 @@ | ||
package com.handstandsam.shoppingapp.tests | ||
|
||
import androidx.lifecycle.Lifecycle | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.typeText | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import com.handstandsam.shoppingapp.R | ||
import com.handstandsam.shoppingapp.features.login.LoginActivity | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
/** | ||
* com.android.test | ||
*/ | ||
class AndroidTestModuleTest { | ||
|
||
@Test | ||
fun androidTestModule() { | ||
assertTrue(true) | ||
} | ||
|
||
@Test | ||
fun androidTestModuleLoginActivityTypeUsernameTest() { | ||
val activityScenario: ActivityScenario<LoginActivity> = | ||
ActivityScenario.launch(LoginActivity::class.java) | ||
|
||
activityScenario.moveToState(Lifecycle.State.RESUMED) | ||
|
||
onView(withId(R.id.username)).perform(typeText("username")) | ||
|
||
activityScenario.moveToState(Lifecycle.State.DESTROYED) | ||
} | ||
} |
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 @@ | ||
plugins { | ||
id 'shoppingapp.android.lib' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
namespace = "com.handstandsam.shoppingapp.android.tests.lib" | ||
|
||
variantFilter { variant -> | ||
setIgnore(!variant.name.toLowerCase().endsWith("debug")) | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly project(path: ':app') | ||
|
||
implementation libs.androidx.espresso | ||
implementation libs.androidx.espresso.contrib | ||
implementation libs.androidx.test.rules | ||
implementation libs.androidx.testrunner | ||
} |
23 changes: 23 additions & 0 deletions
23
app-test-suite/src/main/java/com/handstandsam/shoppingapp/tests/TestInLibraryModuleTest.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,23 @@ | ||
package com.handstandsam.shoppingapp.tests | ||
|
||
import androidx.lifecycle.Lifecycle | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.typeText | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import com.handstandsam.shoppingapp.R | ||
import com.handstandsam.shoppingapp.features.login.LoginActivity | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
/** | ||
* com.android.library | ||
*/ | ||
class TestInLibraryModuleTest { | ||
|
||
@Test | ||
fun testInLibraryModule() { | ||
println("Test in Library Module!") | ||
assertTrue(true) | ||
} | ||
} |
Oops, something went wrong.