mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Update Tests for Profile Activity (#4324)
This commit is contained in:
parent
c269693625
commit
b939db91e0
2 changed files with 11 additions and 45 deletions
|
|
@ -1,34 +0,0 @@
|
||||||
package fr.free.nrw.commons.profile
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import org.junit.Before
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.mockito.Mock
|
|
||||||
import org.mockito.MockitoAnnotations
|
|
||||||
import org.powermock.api.mockito.PowerMockito
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
|
||||||
@PrepareForTest(
|
|
||||||
ProfileActivity::class
|
|
||||||
)
|
|
||||||
class ProfileActivityStartYourself {
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var context: Context
|
|
||||||
|
|
||||||
@Before
|
|
||||||
fun setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Throws(Exception::class)
|
|
||||||
fun testStartYourself() {
|
|
||||||
PowerMockito.mockStatic(ProfileActivity::class.java)
|
|
||||||
ProfileActivity.startYourself(context)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,12 +6,9 @@ import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.powermock.api.mockito.PowerMockito
|
||||||
import org.mockito.MockitoAnnotations
|
|
||||||
import org.powermock.api.mockito.PowerMockito.mockStatic
|
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -20,17 +17,14 @@ import org.robolectric.annotation.Config
|
||||||
class ProfileActivityTest {
|
class ProfileActivityTest {
|
||||||
|
|
||||||
private lateinit var activity: ProfileActivity
|
private lateinit var activity: ProfileActivity
|
||||||
|
private lateinit var profileActivity: ProfileActivity
|
||||||
@Mock
|
private lateinit var mockContext: Context
|
||||||
private lateinit var context: Context
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
|
||||||
|
|
||||||
activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get()
|
activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get()
|
||||||
|
mockContext = PowerMockito.mock(Context::class.java)
|
||||||
context = RuntimeEnvironment.application.applicationContext
|
profileActivity = PowerMockito.mock(ProfileActivity::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -45,4 +39,10 @@ class ProfileActivityTest {
|
||||||
activity.onDestroy()
|
activity.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testStartYourself() {
|
||||||
|
ProfileActivity.startYourself(mockContext)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue