mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Added Tests for Profile Activity (#4062)
This commit is contained in:
		
							parent
							
								
									4ac1b2d338
								
							
						
					
					
						commit
						c1659f2bc0
					
				
					 3 changed files with 92 additions and 2 deletions
				
			
		|  | @ -0,0 +1,34 @@ | |||
| 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) | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,48 @@ | |||
| package fr.free.nrw.commons.profile | ||||
| 
 | ||||
| import android.content.Context | ||||
| import fr.free.nrw.commons.TestCommonsApplication | ||||
| 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.robolectric.Robolectric | ||||
| import org.robolectric.RobolectricTestRunner | ||||
| import org.robolectric.RuntimeEnvironment | ||||
| import org.robolectric.annotation.Config | ||||
| 
 | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner::class) | ||||
| @Config(sdk = [21], application = TestCommonsApplication::class) | ||||
| class ProfileActivityTest { | ||||
| 
 | ||||
|     private lateinit var activity: ProfileActivity | ||||
| 
 | ||||
|     @Mock | ||||
|     private lateinit var context: Context | ||||
| 
 | ||||
|     @Before | ||||
|     fun setUp() { | ||||
|         MockitoAnnotations.initMocks(this) | ||||
| 
 | ||||
|         activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get() | ||||
| 
 | ||||
|         context = RuntimeEnvironment.application.applicationContext | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     @Throws(Exception::class) | ||||
|     fun checkActivityNotNull() { | ||||
|         Assert.assertNotNull(activity) | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     @Throws(Exception::class) | ||||
|     fun testOnDestroy() { | ||||
|         activity.onDestroy() | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Madhur Gupta
						Madhur Gupta