get instrumentation tests running successfully

This commit is contained in:
Sean Mac Gillicuddy 2019-10-01 14:55:01 +01:00
parent 26c203f287
commit f5514cbd72
18 changed files with 47 additions and 60 deletions

View File

@ -9,7 +9,6 @@ buildscript {
dependencies { dependencies {
dependencies { dependencies {
} }
} }
} }
@ -25,8 +24,6 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'jacoco-android' apply plugin: 'jacoco-android'
apply plugin: "org.jlleitschuh.gradle.ktlint" apply plugin: "org.jlleitschuh.gradle.ktlint"
def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER') ?: "dev" def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER') ?: "dev"
ext { ext {
@ -148,6 +145,15 @@ android {
} }
} }
sourceSets {
test {
java.srcDirs += "$rootDir/core/src/testShared"
}
androidTest {
java.srcDirs += "$rootDir/core/src/testShared"
}
}
compileOptions { compileOptions {
encoding = "UTF-8" encoding = "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
@ -232,6 +238,9 @@ dependencies {
androidTestCompileOnly(Libs.javax_annotation_api) androidTestCompileOnly(Libs.javax_annotation_api)
implementation(Libs.dagger) implementation(Libs.dagger)
kaptAndroidTest(Libs.dagger_compiler) kaptAndroidTest(Libs.dagger_compiler)
implementation(Libs.dagger_android)
kapt(Libs.dagger_compiler)
kapt(Libs.dagger_android_processor)
androidTestImplementation(Libs.mockk_android) androidTestImplementation(Libs.mockk_android)
androidTestImplementation(Libs.uiautomator) androidTestImplementation(Libs.uiautomator)
androidTestImplementation(Libs.assertj_core) androidTestImplementation(Libs.assertj_core)
@ -240,4 +249,16 @@ dependencies {
exclude module: 'stax-api' exclude module: 'stax-api'
exclude module: 'xpp3' exclude module: 'xpp3'
} }
implementation(Libs.squidb)
implementation(Libs.squidb_annotations)
kapt(Libs.squidb_processor)
implementation(Libs.xfetch2)
implementation(Libs.xfetch2okhttp)
// RxJava
implementation(Libs.rxandroid)
implementation(Libs.rxjava)
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 3.5.0" client="gradle" variant="debug" version="3.5.0"> <issues format="5" by="lint 3.5.0" client="gradle" variant="all" version="3.5.0">
<issue <issue
id="ObsoleteLintCustomCheck" id="ObsoleteLintCustomCheck"
@ -8,17 +8,6 @@
file="..\..\..\.android\lint\customlint.jar"/> file="..\..\..\.android\lint\customlint.jar"/>
</issue> </issue>
<issue
id="MissingRegistered"
message="Class referenced in the manifest, `org.kiwix.kiwixmobile.zim_manager.ZimManageActivity`, was not found in the project or the libraries"
errorLine1=" &lt;activity"
errorLine2=" ^">
<location
file="src\main\AndroidManifest.xml"
line="143"
column="5"/>
</issue>
<issue <issue
id="OldTargetApi" id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details." message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
@ -26,7 +15,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~"> errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location <location
file="build.gradle" file="build.gradle"
line="68" line="63"
column="5"/> column="5"/>
</issue> </issue>

View File

@ -9,7 +9,8 @@ import androidx.test.rule.ActivityTestRule
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
import org.junit.Rule import org.junit.Rule
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.kiwix.kiwixmobile.di.components.DaggerTestComponent import org.kiwix.kiwixmobile.core.di.components.DaggerTestComponent
import org.kiwix.kiwixmobile.core.di.components.TestComponent
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
abstract class BaseActivityTest<T : Activity> { abstract class BaseActivityTest<T : Activity> {
@ -36,7 +37,7 @@ abstract class BaseActivityTest<T : Activity> {
} }
} }
protected fun testComponent() = DaggerTestComponent.builder() protected fun testComponent(): TestComponent = DaggerTestComponent.builder()
.context(context) .context(context)
.build() .build()
} }

View File

@ -38,8 +38,8 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kiwix.kiwixmobile.core.KiwixApplication; import org.kiwix.kiwixmobile.core.KiwixApplication;
import org.kiwix.kiwixmobile.core.data.ZimContentProvider; import org.kiwix.kiwixmobile.core.data.ZimContentProvider;
import org.kiwix.kiwixmobile.di.components.DaggerTestComponent; import org.kiwix.kiwixmobile.core.di.components.DaggerTestComponent;
import org.kiwix.kiwixmobile.di.components.TestComponent; import org.kiwix.kiwixmobile.core.di.components.TestComponent;
import org.kiwix.kiwixmobile.core.main.MainActivity; import org.kiwix.kiwixmobile.core.main.MainActivity;
import org.kiwix.kiwixmobile.testutils.TestUtils; import org.kiwix.kiwixmobile.testutils.TestUtils;
import org.kiwix.kiwixmobile.utils.KiwixIdlingResource; import org.kiwix.kiwixmobile.utils.KiwixIdlingResource;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.kiwix.kiwixmobile.di.components package org.kiwix.kiwixmobile.core.di.components
import android.content.Context import android.content.Context
import dagger.BindsInstance import dagger.BindsInstance
@ -23,10 +23,9 @@ import dagger.Component
import org.kiwix.kiwixmobile.NetworkTest import org.kiwix.kiwixmobile.NetworkTest
import org.kiwix.kiwixmobile.ZimTest import org.kiwix.kiwixmobile.ZimTest
import org.kiwix.kiwixmobile.core.data.DataModule import org.kiwix.kiwixmobile.core.data.DataModule
import org.kiwix.kiwixmobile.core.di.components.ApplicationComponent
import org.kiwix.kiwixmobile.core.di.modules.ApplicationModule import org.kiwix.kiwixmobile.core.di.modules.ApplicationModule
import org.kiwix.kiwixmobile.core.di.modules.JNIModule import org.kiwix.kiwixmobile.core.di.modules.JNIModule
import org.kiwix.kiwixmobile.di.modules.TestNetworkModule import org.kiwix.kiwixmobile.core.di.modules.TestNetworkModule
import javax.inject.Singleton import javax.inject.Singleton
/** /**

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.kiwix.kiwixmobile.di.modules; package org.kiwix.kiwixmobile.core.di.modules;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;

View File

@ -15,13 +15,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.kiwix.kiwixmobile.di.modules package org.kiwix.kiwixmobile.core.di.modules
import dagger.Module import dagger.Module
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.kiwix.kiwixmobile.core.MOCK_BASE_URL import org.kiwix.kiwixmobile.core.MOCK_BASE_URL
import org.kiwix.kiwixmobile.core.data.remote.KiwixService import org.kiwix.kiwixmobile.core.data.remote.KiwixService
import org.kiwix.kiwixmobile.core.di.modules.NetworkModule
/** /**
* Created by mhutti1 on 14/04/17. * Created by mhutti1 on 14/04/17.

View File

@ -35,7 +35,7 @@ import java.util.ArrayList;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase; import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase;
import org.kiwix.kiwixmobile.data.local.entity.Bookmark; import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;

View File

@ -28,7 +28,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase; import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase;
import org.kiwix.kiwixmobile.core.data.local.dao.BookDao; import org.kiwix.kiwixmobile.core.data.local.dao.BookDao;
import org.kiwix.kiwixmobile.data.local.entity.BookDatabaseEntity; import org.kiwix.kiwixmobile.core.data.local.entity.BookDatabaseEntity;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;

View File

@ -32,7 +32,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kiwix.kiwixmobile.core.R; import org.kiwix.kiwixmobile.core.R;
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity; import org.kiwix.kiwixmobile.core.zim_manager.ZimManageActivity;
import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.click;

View File

@ -13,6 +13,7 @@ import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity
import org.kiwix.kiwixmobile.core.libraryNetworkEntity import org.kiwix.kiwixmobile.core.libraryNetworkEntity
import org.kiwix.kiwixmobile.core.metaLinkNetworkEntity import org.kiwix.kiwixmobile.core.metaLinkNetworkEntity
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.core.zim_manager.ZimManageActivity
import java.util.concurrent.TimeUnit.SECONDS import java.util.concurrent.TimeUnit.SECONDS
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR2) @SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR2)

View File

@ -141,7 +141,7 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".zim_manager.ZimManageActivity" android:name=".core.zim_manager.ZimManageActivity"
android:label="@string/choose_file" android:label="@string/choose_file"
android:launchMode="singleTop"> android:launchMode="singleTop">
<!-- TODO --> <!-- TODO -->

View File

@ -130,7 +130,7 @@ dependencies {
// Get kiwixlib online if it is not populated locally // Get kiwixlib online if it is not populated locally
if (!shouldUseLocalVersion()) { if (!shouldUseLocalVersion()) {
implementation(Libs.kiwixlib) api(Libs.kiwixlib)
} else { } else {
implementation 'com.getkeepsafe.relinker:relinker:1.3.1' implementation 'com.getkeepsafe.relinker:relinker:1.3.1'
implementation fileTree(include: ['*.aar'], dir: 'libs') implementation fileTree(include: ['*.aar'], dir: 'libs')

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 3.5.0" client="gradle" variant="debug" version="3.5.0"> <issues format="5" by="lint 3.5.0" client="gradle" variant="all" version="3.5.0">
<issue <issue
id="ObsoleteLintCustomCheck" id="ObsoleteLintCustomCheck"

View File

@ -1,24 +0,0 @@
package org.kiwix.kiwixmobile.core
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.kiwix.kiwixmobile.core.test", appContext.packageName)
}
}

View File

@ -193,7 +193,8 @@ class NetworkUtilsTest {
every { (context.getString(R.string.zim_no_vid)) } returns "No Videos" every { (context.getString(R.string.zim_no_vid)) } returns "No Videos"
every { (context.getString(R.string.zim_simple)) } returns "Simple" every { (context.getString(R.string.zim_simple)) } returns "Simple"
assertEquals("URL Parsing on empty string", "", assertEquals(
"URL Parsing on empty string", "",
NetworkUtils.parseURL(context, "") NetworkUtils.parseURL(context, "")
) )

View File

@ -10,7 +10,7 @@
<issue <issue
id="MissingRegistered" id="MissingRegistered"
message="Class referenced in the manifest, `org.kiwix.kiwixmobile.zim_manager.ZimManageActivity`, was not found in the project or the libraries" message="Class referenced in the manifest, `org.kiwix.kiwixmobile.core.zim_manager.ZimManageActivity`, was not found in the project or the libraries"
errorLine1=" &lt;activity" errorLine1=" &lt;activity"
errorLine2=" ^"> errorLine2=" ^">
<location <location
@ -48,7 +48,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~"> errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location <location
file="build.gradle" file="build.gradle"
line="36" line="38"
column="5"/> column="5"/>
</issue> </issue>

View File

@ -141,7 +141,7 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".zim_manager.ZimManageActivity" android:name=".core.zim_manager.ZimManageActivity"
android:label="@string/choose_file" android:label="@string/choose_file"
android:launchMode="singleTop"> android:launchMode="singleTop">
<!-- TODO --> <!-- TODO -->