Created
November 2, 2015 20:51
-
-
Save HannahMitt/b26190778e9091d168b8 to your computer and use it in GitHub Desktop.
Example JUnit4 Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.etsy.android.perf; | |
import android.app.Instrumentation; | |
import android.support.test.InstrumentationRegistry; | |
import android.support.test.runner.AndroidJUnit4; | |
import android.test.suitebuilder.annotation.LargeTest; | |
import com.etsy.android.BOEApplication; | |
import com.etsy.android.test.rules.EtsyAccountRule; | |
import com.etsy.android.test.rules.EtsyConfigRule; | |
import com.etsy.android.test.EtsyFunctionalTestTimer; | |
import org.junit.ClassRule; | |
import org.junit.Test; | |
import org.junit.Before; | |
import org.junit.runner.RunWith; | |
import static junit.framework.Assert.assertNotNull; | |
/** | |
* A test to measure the time it takes for the application to start up | |
*/ | |
@RunWith(AndroidJUnit4.class) | |
@LargeTest | |
public class ApplicationLaunchTests { | |
@ClassRule | |
public static EtsyConfigRule mConfigRule = new EtsyConfigRule(); | |
@ClassRule | |
public static EtsyAccountRule mAccountRule = EtsyAccountRule.noAccount(); | |
@Before | |
public void setup() { | |
} | |
@Test | |
public void testApplicationStartupTime_signedOut() throws IllegalAccessException, ClassNotFoundException, InstantiationException { | |
EtsyFunctionalTestTimer appLaunchTimer = EtsyFunctionalTestTimer.time(PerfConstants.APP_LAUNCH_TIME); | |
final BOEApplication application = (BOEApplication) Instrumentation.newApplication(BOEApplication.class, InstrumentationRegistry.getTargetContext()); | |
assertNotNull(application); | |
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { | |
@Override | |
public void run() { | |
application.onCreate(); | |
} | |
}); | |
appLaunchTimer.stop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment