diff --git a/app/build.gradle b/app/build.gradle index 7b7aacec..262d8b14 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -80,6 +80,10 @@ android { packagingOptions { exclude 'META-INF/licenses/ASM' } + + if (gradle.startParameter.taskNames.any { it.contains("Firebase") }) { + sourceSets.androidTest.java.srcDirs += ["../feature/about/src/androidTest/java"] + } } dependencies { @@ -176,7 +180,7 @@ play { } project.afterEvaluate { - if (gradle.startParameter.taskNames.any{ it.startsWith("publishBundle")}) { + if (gradle.startParameter.taskNames.any { it.startsWith("publishBundle") }) { def credentials = System.getenv("PLAY_PUBLISHER_CREDENTIALS") if (credentials == null) { throw new GradleException("PLAY_PUBLISHER_CREDENTIALS not set, cannot release") diff --git a/feature/about/build.gradle b/feature/about/build.gradle index 9eabd3ac..5a60d0c6 100644 --- a/feature/about/build.gradle +++ b/feature/about/build.gradle @@ -6,6 +6,8 @@ android { compileSdkVersion 30 defaultConfig { minSdkVersion 24 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } compileOptions { @@ -35,4 +37,8 @@ dependencies { testImplementation 'androidx.arch.core:core-testing:2.1.0' testImplementation 'org.mockito:mockito-core:3.8.0' testImplementation project(':core-testing') + + androidTestImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'org.assertj:assertj-core:3.19.0' } diff --git a/feature/about/src/androidTest/java/com/jraska/github/client/about/VersionInfoModelTest.kt b/feature/about/src/androidTest/java/com/jraska/github/client/about/VersionInfoModelTest.kt new file mode 100644 index 00000000..52f56796 --- /dev/null +++ b/feature/about/src/androidTest/java/com/jraska/github/client/about/VersionInfoModelTest.kt @@ -0,0 +1,23 @@ +package com.jraska.github.client.about + +import android.view.LayoutInflater +import android.widget.FrameLayout +import android.widget.TextView + +import androidx.test.platform.app.InstrumentationRegistry +import org.assertj.core.api.Assertions.assertThat +import org.junit.Test + +internal class VersionInfoModelTest { + @Test + fun bindsProperly() { + val context = InstrumentationRegistry.getInstrumentation().targetContext + val frameLayout = FrameLayout(context) + + val versionInfoModel = VersionInfoModel() + val view = LayoutInflater.from(context).inflate(versionInfoModel.layout, frameLayout) + versionInfoModel.bind(view) + + assertThat(view.findViewById(R.id.version_name_and_code).text).contains("Version") + } +} diff --git a/feature/about/src/main/java/com/jraska/github/client/about/VersionInfoModel.kt b/feature/about/src/main/java/com/jraska/github/client/about/VersionInfoModel.kt index a912765e..46911b26 100644 --- a/feature/about/src/main/java/com/jraska/github/client/about/VersionInfoModel.kt +++ b/feature/about/src/main/java/com/jraska/github/client/about/VersionInfoModel.kt @@ -5,7 +5,7 @@ import android.widget.TextView import androidx.core.content.pm.PackageInfoCompat import com.airbnb.epoxy.SimpleEpoxyModel -internal class VersionInfoModel : SimpleEpoxyModel(R.layout.about_item_version) { +class VersionInfoModel : SimpleEpoxyModel(R.layout.about_item_version) { override fun bind(view: View) { super.bind(view)