安卓测试 : Target app vs Test app?

标签 android unit-testing android-testing

谁能给我解释一下目标应用Context测试应用Context之间的区别?

You can use the InstrumentationRegistry class to access information related to your test run. This class includes the Instrumentation object, target app Context object, test app Context object, and the command line arguments passed into your test.

Android 开发人员指南的以下摘录(此处:https://developer.android.com/tools/testing-support-library/index.html)是我试图理解的内容。

最佳答案

目标应用你的应用。即正在测试的应用程序。又名“正在测试的应用程序”。如果您想与应用程序中的内容进行交互 - 加载应用程序资源、发送 Intent 等,请在测试中使用它。

测试应用是一个特殊的应用,其中包含用于测试的代码和资源,并且具有特殊权限,可以在您的应用中浏览通常不会向其他应用公开的内容。如果您想加载仅供测试的资源,请使用它。

关于安卓测试 : Target app vs Test app?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32042410/

相关文章:

python - 如何模拟在不同模块的导入方法中导入的函数

unit-testing - 如何在不使用 Thread.sleep 的情况下对向自身发送消息的 Akka Actor 进行单元测试

c++ - 如何在 cppunit 中断言语句抛出 Excp1 或 Excp2 类型的异常?

android - "How to concisely implement an editable table layout"

java - 从软键盘捕获 "DONE"按键

android - 如何从 AlertDialog 中的 EditText 中检索值?

android - 如何使用最新的 ActivityScenarioRule/ActivityScenario 放置额外数据?[Espresso/Jetpack]

Android - 如何设置 keystore

ui-automation - 用于测试的 Webview 元素检查

android - 测试 apk multidexed 不会在 api-19 上运行