I'm using the new Android Testing Support Library (com.android.support.test:runner:0.2
) to run Instrumentation Tests
(a.k.a Device or Emulator Tests).
I annotate my test class with @RunWith(AndroidJUnit4.class)
and use Android Studio to run them.
For my test cases I need a Context
instance. I can get it with InstrumentationRegistry
but it has two context related methods and it's not clear what the difference is.
What is the difference between InstrumentationRegistry.getContext()
vs. InstrumentationRegistry.getTargetContext()
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…