Add timeouts
This commit is contained in:
parent
dc20fb31ee
commit
90379eb30c
|
@ -6,10 +6,8 @@ import com.h.pixeldroid.db.AppDatabase
|
|||
import com.h.pixeldroid.db.PostDao
|
||||
import com.h.pixeldroid.db.PostEntity
|
||||
import com.h.pixeldroid.utils.*
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.*
|
||||
import org.junit.rules.Timeout
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.Calendar
|
||||
|
||||
|
@ -18,7 +16,8 @@ class AppDatabaseTest {
|
|||
private var postDao: PostDao? = null
|
||||
private var db: AppDatabase? = null
|
||||
private var postTest = PostEntity(1, "test", date= Calendar.getInstance().time)
|
||||
|
||||
@Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||
@Before
|
||||
fun setup() {
|
||||
AppDatabase.TEST_MODE = true
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package com.h.pixeldroid
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* 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("com.h.pixeldroid", appContext.packageName)
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import org.hamcrest.Matcher
|
|||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.Timeout
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
|
||||
|
@ -37,6 +38,8 @@ import org.junit.runner.RunWith
|
|||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LoginInstrumentedTest {
|
||||
@Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||
@get:Rule
|
||||
var activityRule: ActivityScenarioRule<LoginActivity>
|
||||
= ActivityScenarioRule(LoginActivity::class.java)
|
||||
|
@ -63,6 +66,8 @@ class LoginInstrumentedTest {
|
|||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LoginCheckIntent {
|
||||
@Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||
@get:Rule
|
||||
val intentsTestRule = IntentsTestRule(LoginActivity::class.java)
|
||||
|
||||
|
@ -85,6 +90,8 @@ class LoginCheckIntent {
|
|||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class AfterIntent {
|
||||
@Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||
|
||||
@get:Rule
|
||||
val rule = ActivityTestRule(LoginActivity::class.java)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,7 @@ import androidx.test.platform.app.InstrumentationRegistry
|
|||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.Timeout
|
||||
import org.junit.runner.RunWith
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
|
@ -24,6 +25,8 @@ class SettingsTest {
|
|||
@get:Rule
|
||||
var activityRule: ActivityScenarioRule<MainActivity>
|
||||
= ActivityScenarioRule(MainActivity::class.java)
|
||||
@Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||
|
||||
@Before
|
||||
fun before(){
|
||||
|
@ -35,7 +38,7 @@ class SettingsTest {
|
|||
|
||||
}
|
||||
|
||||
/*@Test
|
||||
@Test
|
||||
fun testDrawerSettingsButton() {
|
||||
// Open Drawer to click on navigation.
|
||||
onView(withId(R.id.drawer_layout))
|
||||
|
@ -47,6 +50,6 @@ class SettingsTest {
|
|||
|
||||
// Check that settings activity was opened.
|
||||
onView(withText(R.string.signature_title)).check(matches(isDisplayed()))
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ import com.google.android.material.tabs.TabLayout
|
|||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.Timeout
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
@ -22,6 +23,8 @@ class SwipeTest {
|
|||
@get:Rule
|
||||
var activityRule: ActivityScenarioRule<MainActivity>
|
||||
= ActivityScenarioRule(MainActivity::class.java)
|
||||
@Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||
@Before
|
||||
fun before(){
|
||||
val preferences = getInstrumentation()
|
||||
|
|
Loading…
Reference in New Issue