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.PostDao
|
||||||
import com.h.pixeldroid.db.PostEntity
|
import com.h.pixeldroid.db.PostEntity
|
||||||
import com.h.pixeldroid.utils.*
|
import com.h.pixeldroid.utils.*
|
||||||
import org.junit.After
|
import org.junit.*
|
||||||
import org.junit.Assert
|
import org.junit.rules.Timeout
|
||||||
import org.junit.Before
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
@ -18,7 +16,8 @@ class AppDatabaseTest {
|
|||||||
private var postDao: PostDao? = null
|
private var postDao: PostDao? = null
|
||||||
private var db: AppDatabase? = null
|
private var db: AppDatabase? = null
|
||||||
private var postTest = PostEntity(1, "test", date= Calendar.getInstance().time)
|
private var postTest = PostEntity(1, "test", date= Calendar.getInstance().time)
|
||||||
|
@Rule
|
||||||
|
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
AppDatabase.TEST_MODE = true
|
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.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.junit.rules.Timeout
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
|
||||||
@ -37,6 +38,8 @@ import org.junit.runner.RunWith
|
|||||||
*/
|
*/
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class LoginInstrumentedTest {
|
class LoginInstrumentedTest {
|
||||||
|
@Rule
|
||||||
|
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||||
@get:Rule
|
@get:Rule
|
||||||
var activityRule: ActivityScenarioRule<LoginActivity>
|
var activityRule: ActivityScenarioRule<LoginActivity>
|
||||||
= ActivityScenarioRule(LoginActivity::class.java)
|
= ActivityScenarioRule(LoginActivity::class.java)
|
||||||
@ -63,6 +66,8 @@ class LoginInstrumentedTest {
|
|||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class LoginCheckIntent {
|
class LoginCheckIntent {
|
||||||
|
@Rule
|
||||||
|
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val intentsTestRule = IntentsTestRule(LoginActivity::class.java)
|
val intentsTestRule = IntentsTestRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@ -85,6 +90,8 @@ class LoginCheckIntent {
|
|||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class AfterIntent {
|
class AfterIntent {
|
||||||
|
@Rule
|
||||||
|
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val rule = ActivityTestRule(LoginActivity::class.java)
|
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.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.junit.rules.Timeout
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
@ -24,6 +25,8 @@ class SettingsTest {
|
|||||||
@get:Rule
|
@get:Rule
|
||||||
var activityRule: ActivityScenarioRule<MainActivity>
|
var activityRule: ActivityScenarioRule<MainActivity>
|
||||||
= ActivityScenarioRule(MainActivity::class.java)
|
= ActivityScenarioRule(MainActivity::class.java)
|
||||||
|
@Rule
|
||||||
|
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun before(){
|
fun before(){
|
||||||
@ -35,7 +38,7 @@ class SettingsTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Test
|
@Test
|
||||||
fun testDrawerSettingsButton() {
|
fun testDrawerSettingsButton() {
|
||||||
// Open Drawer to click on navigation.
|
// Open Drawer to click on navigation.
|
||||||
onView(withId(R.id.drawer_layout))
|
onView(withId(R.id.drawer_layout))
|
||||||
@ -47,6 +50,6 @@ class SettingsTest {
|
|||||||
|
|
||||||
// Check that settings activity was opened.
|
// Check that settings activity was opened.
|
||||||
onView(withText(R.string.signature_title)).check(matches(isDisplayed()))
|
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.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.junit.rules.Timeout
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@ -22,6 +23,8 @@ class SwipeTest {
|
|||||||
@get:Rule
|
@get:Rule
|
||||||
var activityRule: ActivityScenarioRule<MainActivity>
|
var activityRule: ActivityScenarioRule<MainActivity>
|
||||||
= ActivityScenarioRule(MainActivity::class.java)
|
= ActivityScenarioRule(MainActivity::class.java)
|
||||||
|
@Rule
|
||||||
|
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||||
@Before
|
@Before
|
||||||
fun before(){
|
fun before(){
|
||||||
val preferences = getInstrumentation()
|
val preferences = getInstrumentation()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user