Skip to content

Commit

Permalink
Fixing Tests
Browse files Browse the repository at this point in the history
- use androidx package tools instead of android.support package
- testing progress dialog is broken as the framework tends to go in
  a deadlock; hence removed

Signed-off-by: Arka Prava Basu <arkaprava94@gmail.com>
  • Loading branch information
archie94 committed Nov 10, 2018
1 parent b11c3d0 commit 68cf160
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 69 deletions.
13 changes: 9 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ android {
abiFilters "armeabi", "armeabi-v7a", "x86"
}

testInstrumentationRunner "android.test.InstrumentationTestRunner"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// clear app state completely between tests
testInstrumentationRunnerArguments clearPackageData: 'true'

javaCompileOptions {
annotationProcessorOptions {
Expand Down Expand Up @@ -170,8 +172,11 @@ dependencies {
implementation "android.arch.lifecycle:extensions:1.1.1"

testImplementation "junit:junit:4.12"
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:3.0.2"
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:core:1.0.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation "android.arch.persistence.room:testing:1.1.1"

// android-job
Expand Down
58 changes: 0 additions & 58 deletions src/androidTest/java/org/havenapp/main/ListActivityTest.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.havenapp.main.database.migration

import android.arch.persistence.db.framework.FrameworkSQLiteOpenHelperFactory
import android.arch.persistence.room.Room
import android.arch.persistence.room.testing.MigrationTestHelper
import android.support.test.InstrumentationRegistry
import androidx.test.core.app.ApplicationProvider
import androidx.room.Room
import androidx.room.testing.MigrationTestHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.Assert.assertEquals
import org.havenapp.main.database.HavenEventDB
import org.havenapp.main.database.converter.HavenEventDBConverters.Companion.dateToTimestamp
import org.junit.After
import org.junit.Before
Expand All @@ -17,7 +19,7 @@ import org.junit.Test
class RoomMigrationTest {
@get:Rule
val migrationTestHelper = MigrationTestHelper(InstrumentationRegistry.getInstrumentation(),
org.havenapp.main.database.HavenEventDB::class.java.canonicalName,
HavenEventDB::class.java.canonicalName,
FrameworkSQLiteOpenHelperFactory())

private var sugarDbOpenHelper: SugarDbOpenHelper? = null
Expand All @@ -27,7 +29,7 @@ class RoomMigrationTest {
@Before
fun setUpDb() {
sugarDbOpenHelper =
SugarDbOpenHelper(InstrumentationRegistry.getTargetContext(), TEST_DB_NAME)
SugarDbOpenHelper(ApplicationProvider.getApplicationContext(), TEST_DB_NAME)
SugarDbTestHelper.createTables(sugarDbOpenHelper!!)
}

Expand Down Expand Up @@ -57,7 +59,7 @@ class RoomMigrationTest {
}

private fun getMigratedRoomDb(): org.havenapp.main.database.HavenEventDB {
val db = Room.databaseBuilder(InstrumentationRegistry.getTargetContext(),
val db = Room.databaseBuilder(ApplicationProvider.getApplicationContext(),
org.havenapp.main.database.HavenEventDB::class.java, TEST_DB_NAME)
.addMigrations(RoomMigration())
.build()
Expand Down

0 comments on commit 68cf160

Please sign in to comment.