mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +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.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.api.mockito.PowerMockito.mockStatic
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
|
||||
|
|
@ -20,17 +17,14 @@ import org.robolectric.annotation.Config
|
|||
class ProfileActivityTest {
|
||||
|
||||
private lateinit var activity: ProfileActivity
|
||||
|
||||
@Mock
|
||||
private lateinit var context: Context
|
||||
private lateinit var profileActivity: ProfileActivity
|
||||
private lateinit var mockContext: Context
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
|
||||
activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get()
|
||||
|
||||
context = RuntimeEnvironment.application.applicationContext
|
||||
mockContext = PowerMockito.mock(Context::class.java)
|
||||
profileActivity = PowerMockito.mock(ProfileActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -45,4 +39,10 @@ class ProfileActivityTest {
|
|||
activity.onDestroy()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testStartYourself() {
|
||||
ProfileActivity.startYourself(mockContext)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue