Add first Kaspresso test
This commit is contained in:
@@ -17,6 +17,7 @@ android {
|
||||
applicationId = "gq.kirmanak.mealient"
|
||||
versionCode = 25
|
||||
versionName = "0.3.10"
|
||||
testInstrumentationRunner = "gq.kirmanak.mealient.MealientTestRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -89,6 +90,8 @@ dependencies {
|
||||
kapt(libs.google.dagger.hiltCompiler)
|
||||
kaptTest(libs.google.dagger.hiltAndroidCompiler)
|
||||
testImplementation(libs.google.dagger.hiltAndroidTesting)
|
||||
kaptAndroidTest(libs.google.dagger.hiltAndroidCompiler)
|
||||
androidTestImplementation(libs.google.dagger.hiltAndroidTesting)
|
||||
|
||||
implementation(libs.androidx.paging.runtimeKtx)
|
||||
testImplementation(libs.androidx.paging.commonKtx)
|
||||
@@ -122,4 +125,11 @@ dependencies {
|
||||
testImplementation(libs.io.mockk)
|
||||
|
||||
debugImplementation(libs.squareup.leakcanary)
|
||||
|
||||
androidTestImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.test.junit)
|
||||
androidTestImplementation(libs.kaspersky.kaspresso)
|
||||
androidTestImplementation(libs.androidx.test.core)
|
||||
androidTestImplementation(libs.androidx.test.rules)
|
||||
androidTestImplementation(libs.androidx.test.runner)
|
||||
}
|
||||
4
app/src/androidTest/AndroidManifest.xml
Normal file
4
app/src/androidTest/AndroidManifest.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Needed for screenshots in Kaspresso -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
||||
@@ -0,0 +1,32 @@
|
||||
package gq.kirmanak.mealient
|
||||
|
||||
import androidx.test.ext.junit.rules.activityScenarioRule
|
||||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
|
||||
import dagger.hilt.android.testing.HiltAndroidRule
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import gq.kirmanak.mealient.screen.DisclaimerScreen
|
||||
import gq.kirmanak.mealient.ui.activity.MainActivity
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@HiltAndroidTest
|
||||
class FirstSetUpTest : TestCase() {
|
||||
|
||||
@get:Rule(order = 0)
|
||||
var hiltRule = HiltAndroidRule(this)
|
||||
|
||||
@get:Rule(order = 1)
|
||||
val mainActivityRule = activityScenarioRule<MainActivity>()
|
||||
|
||||
@Test
|
||||
fun test() = run {
|
||||
step("Ensure button is disabled") {
|
||||
DisclaimerScreen {
|
||||
okayButton {
|
||||
isVisible()
|
||||
isDisabled()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package gq.kirmanak.mealient
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.test.runner.AndroidJUnitRunner
|
||||
import dagger.hilt.android.testing.HiltTestApplication
|
||||
|
||||
class MealientTestRunner : AndroidJUnitRunner() {
|
||||
|
||||
override fun newApplication(
|
||||
cl: ClassLoader?,
|
||||
className: String?,
|
||||
context: Context?,
|
||||
): Application = super.newApplication(cl, HiltTestApplication::class.java.name, context)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package gq.kirmanak.mealient.screen
|
||||
|
||||
import com.kaspersky.kaspresso.screens.KScreen
|
||||
import gq.kirmanak.mealient.R
|
||||
import gq.kirmanak.mealient.ui.activity.MainActivity
|
||||
import io.github.kakaocup.kakao.text.KButton
|
||||
|
||||
object DisclaimerScreen : KScreen<DisclaimerScreen>() {
|
||||
override val layoutId = R.layout.fragment_disclaimer
|
||||
override val viewClass = MainActivity::class.java
|
||||
|
||||
val okayButton = KButton { withId(R.id.okay) }
|
||||
}
|
||||
@@ -77,6 +77,10 @@ desugar = "1.2.2"
|
||||
kspPlugin = "1.7.20-1.0.7"
|
||||
# https://developer.android.com/jetpack/androidx/releases/sharetarget
|
||||
shareTarget = "1.2.0"
|
||||
# https://github.com/KasperskyLab/Kaspresso/releases
|
||||
kaspresso = "1.4.2"
|
||||
# https://developer.android.com/jetpack/androidx/releases/test
|
||||
androidXTest = "1.5.0"
|
||||
|
||||
[libraries]
|
||||
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
|
||||
@@ -133,6 +137,10 @@ androidx-room-testing = { group = "androidx.room", name = "room-testing", versio
|
||||
androidx-test-junit = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "junitKtx" }
|
||||
androidx-security-crypto = { group = "androidx.security", name = "security-crypto", version.ref = "security" }
|
||||
|
||||
androidx-test-core = { group = "androidx.test", name = "core", version.ref = "androidXTest" }
|
||||
androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "androidXTest" }
|
||||
androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidXTest" }
|
||||
|
||||
jakewharton-retrofitSerialization = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "retrofitKotlinxSerialization" }
|
||||
|
||||
squareup-retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
|
||||
@@ -158,6 +166,8 @@ io-mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
|
||||
|
||||
chuckerteam-chucker = { group = "com.github.chuckerteam.chucker", name = "library", version.ref = "chucker" }
|
||||
|
||||
kaspersky-kaspresso = { group = "com.kaspersky.android-components", name = "kaspresso", version.ref = "kaspresso" }
|
||||
|
||||
[plugins]
|
||||
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }
|
||||
rootcoverage = { id = "nl.neotech.plugin.rootcoverage", version.ref = "rootCoverage" }
|
||||
|
||||
Reference in New Issue
Block a user