Created
September 5, 2012 16:04
-
-
Save naosim/3639063 to your computer and use it in GitHub Desktop.
AndroidTestCaseからテストプロジェクトのContextを取得する方法
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
public class HogeTest extends AndroidTestCase { | |
/** | |
* AndroidTestCaseからテストプロジェクトのContextを取得する | |
* @return | |
*/ | |
public Context getTestProjectContext() { | |
try { | |
// リフレクションで取得 | |
Method method = getClass().getMethod("getTestContext"); | |
return (Context) method.invoke(this); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment