[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Translation issue"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples/Code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
测试应用组件集成
如果您的应用使用了用户不直接与之互动的组件(如服务或内容提供器),您应验证这些组件在应用中的行为方式是否正确。
在开发此类组件时,您应养成编写集成测试的习惯,以便当您的应用在设备或模拟器上运行时验证组件的行为。
注意:Android 不为 BroadcastReceiver
提供单独的测试用例类。如需验证 BroadcastReceiver
是否正确响应,您可以测试向其发送 Intent
对象的组件。或者,您可以通过调用 ApplicationProvider.getApplicationContext()
来创建 BroadcastReceiver
的实例,然后调用要测试的 BroadcastReceiver
方法(通常,这是 onReceive()
方法)。
本课程教您如何使用 Android 平台提供的测试 API 和工具来构建自动化集成测试。
课程
- 测试您的服务
- 了解如何构建集成测试来验证服务能否在您的应用中正常运行。
- 测试您的内容提供器
- 了解如何构建集成测试来验证内容提供器能否在您的应用中正常运行。
其他资源
要详细了解本主题,请参阅下面列出的其他资源。
示例
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Translation issue"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples/Code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-06-11 UTC.