fix typo and revise document structure

This commit is contained in:
swordstream
2017-07-21 23:57:26 +08:00
parent 59153e014b
commit f29693e6fb
2 changed files with 8 additions and 8 deletions
@@ -5,7 +5,7 @@
* 由于Instrumentation的数据存在于内存中,因此你还需要实现一个BroadCastReceiver,用于在Instrumentation结束时将Instrument结果输出到手机存储器的文件中。
## 项目结构
* 你的项目需要看起来类似如下的结构
你的项目需要看起来类似如下的结构
```
src/main/java/com/example/pkg
|____ MainActivity.java 你的主Activity
@@ -15,14 +15,14 @@ src/main/java/com/example/pkg
|____ EndEmmaBroadCast.java 用于接受结束信号广播的接收器,它将调用InstrumentActivityListener并导出覆盖率。
```
* 你在配置Caps时要做如下设置
你在配置Caps时要做如下设置
`automationName` `uiautomator2` (无视大小写)
`androidCoverage` {package}/{instrumentation class}, 在我们的例子中是com.example.pkg/com.example.pkg.JacocoInstrumentation
`appWaitActivity` 用作Insutrment的Activity的全名,在我们的例子中是com.example.pkg.InstrumentActivity
`appWaitPackage` : {package},在我们的例子中是com.example.pkg
`androidCoverageEndIntent` : 用作将当前coverage输出至文件中的BroadCasterReceiver的Action名,在我们的例子中是 `com.example.pkg.END_EMMA`
* 工作原理
工作原理
Appium 会用类似的命令启动应用:`adb shell am instrument -e coverage true -w com.example.pkg/com.example.pkg.JacocoInstrumentation`
在测试完成后,会用`adb shell am broadcast -a com.example.pkg.END_EMMA` 使覆盖率可以被收集(前提是你亲自实现它)
@@ -1,27 +1,27 @@
# Android Coverage Guide
## Requirement
* Only Emulators or rooted phones are acceptable
* Need add UiAutomator2 supprt in your apps. That is to say, you need implement a subclass of `Instrumentation`. `Instrumentation` will be responsible to collect your coverage.
* Need to add UiAutomator2 support in your apps. That is to say, you need to implement a subclass of `Instrumentation`. `Instrumentation` will be responsible to collect your coverage.
* Need to implement a BroadcastReceiver to export coverage to disk files. This is because `Instrumentation` only collects data into memory.
## Project Structure
* You may need the following structure of files:
You may need the following structure of files:
```
src/main/java/com/example/pkg
|____ MainActivity.java *Your main activity*
|____ InstrumentActivityListener.java *A customized interface for exporting coverage to files*
|____ InstrumentActivity.java *Activity launched for coverage. But in most cases, this should be same as MainActivity. The only difference is that it will include a `InstrumentActivityListener` to export coverage data to disk files.
|____ JacocoInstrumentation.java The instrument class created by you. Also it needs implemeting InstrumentActivitylistener.
|____ JacocoInstrumentation.java The instrument class created by you. Also it needs to implement `InstrumentActivitylistener`.
|____ EndEmmaBroadCast.java A broadcast receiver which will be invoked by appium-uiautomator2-driver at the end of testing. You need implementing logic to invoke InstrumentActivityListener so as to export coverage to files.
```
* Configure followings in your caps
Configure followings in your caps:
`automationName` `uiautomator2` (case irrelevant)
`androidCoverage` {package}/{instrumentation class}, in our example, `com.example.pkg/com.example.pkg.JacocoInstrumentation`
`appWaitActivity` the FQCN of the activity of InstrumentActivity, in our example, `com.example.pkg.InstrumentActivity`
`appWaitPackage` {package}in our example, `com.example.pkg`
`androidCoverageEndIntent` The action of the broadcast receiver to invoke the exporting of coverage data to files, in our example `com.example.pkg.END_EMMA`
* Methodology
Methodology
Appium (appium-uiautomator2-driver) will launch app via command like`adb shell am instrument -e coverage true -w com.example.pkg/com.example.pkg.JacocoInstrumentation`
After testing is done, Appium (appium-uiautomator2-driver) will execute `adb shell am broadcast -a com.example.pkg.END_EMMA` to export coverage to filesIf you implement such export in the broadcast receiver