diff --git a/app/build.gradle b/app/build.gradle index 98c8a8bd21..743bb18b73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -79,6 +79,7 @@ android { multiDexEnabled true buildConfigField "String", "GitHash", "\"${getGitHash()}\"" buildConfigField "String", "BuildDate", "\"${new Date().format('dd/MM/YY HH:mm:ss')}\"" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -140,6 +141,7 @@ android { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } + } dependencies { @@ -208,6 +210,34 @@ dependencies { testImplementation 'org.hamcrest:hamcrest-library:2.2' testImplementation 'org.mockito:mockito-core:3.3.3' testImplementation 'junit:junit:4.13' + + // Android UI testing + + // Core library + androidTestImplementation 'androidx.test:core:1.2.0' + + // AndroidJUnitRunner and JUnit Rules + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test:rules:1.2.0' + + // Assertions + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.ext:truth:1.2.0' + androidTestImplementation 'com.google.truth:truth:0.42' + + // Espresso dependencies + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0' + androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.2.0' + + // The following Espresso dependency can be either "implementation" + // or "androidTestImplementation", depending on whether you want the + // dependency to appear on your APK's compile classpath or the test APK + // classpath. + androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.2.0' } repositories { diff --git a/app/src/androidTest/java/net/bible/android/MainBibleActivityTests.kt b/app/src/androidTest/java/net/bible/android/MainBibleActivityTests.kt new file mode 100644 index 0000000000..6d1e342e19 --- /dev/null +++ b/app/src/androidTest/java/net/bible/android/MainBibleActivityTests.kt @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Martin Denham, Tuomas Airaksinen and the And Bible contributors. + * + * This file is part of And Bible (http://github.com/AndBible/and-bible). + * + * And Bible is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software Foundation, + * either version 3 of the License, or (at your option) any later version. + * + * And Bible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with And Bible. + * If not, see http://www.gnu.org/licenses/. + * + */ + +package net.bible.android + +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.matcher.ViewMatchers.withId +import org.junit.runner.RunWith +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.LargeTest +import androidx.test.rule.ActivityTestRule +import net.bible.android.activity.R + +import net.bible.android.view.activity.page.MainBibleActivity +import org.junit.Rule +import org.junit.Test + +@RunWith(AndroidJUnit4::class) +@LargeTest +class MainBibleActivityTests { + @get:Rule var activityRule: ActivityTestRule + = ActivityTestRule(MainBibleActivity::class.java) + + @Test + fun testMainActivity() { + //mainBibleActivity.windowControl.activeWindowPageManager.currentPage.key = + onView(withId(R.id.speakButton)) + } +}