Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumented test in modules #477

Merged
merged 5 commits into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions feature/about/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 24

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
Expand Down Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
@@ -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<TextView>(R.id.version_name_and_code).text).contains("Version")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down