dnk*_*tso 6 instrumentation android android-testing
我正在为我的应用程序编写仪器测试,并希望创建一个临时文件夹来存储一些文件。但是,我不想在 targetContext 中执行此操作,而是在测试上下文中执行此操作。
换句话说:
// Works, but this creates the folder in the target app.
File dir = getInstrumentation().**getTargetContext()**.getDir("directory", MODE_WORLD_READABLE);
// Does not work, the exists() returns false.
File dir = getInstrumentation().**getContext()**.getDir("directory", MODE_WORLD_READABLE);
Run Code Online (Sandbox Code Playgroud)
我尝试了很多其他的东西,似乎实现Instrumentation context忽略了这些调用?
想法?
| 归档时间: |
|
| 查看次数: |
303 次 |
| 最近记录: |