首页 \ 问答 \ kailLinux 所支持的网卡的型号 最好是TP-link 或IP-Time

kailLinux 所支持的网卡的型号 最好是TP-link 或IP-Time

更新时间:2022-10-12 15:10

最满意答案

在数百次搜索覆盖报告的答案后,我终于找到了我想要的确切答案。

这篇博文中 ,我发现gradlew createDebugCoverageReport创建了jacoco覆盖率报告。

另外,从gradle插件源代码中 ,该插件默认使用jacoco 0.6.2.201302030002。 (因此,如果要使用默认版本,则不需要jacoco版本定义

总之,使用Android gradle插件获取jacoco覆盖率报告的基本步骤是:

  1. Android Gradle插件版本为0.10.0或更高版本(通常在您项目的build.gradle
  2. testCoverageEnabled true添加到您想要的构建类型(即debug
  3. 运行$ gradlew createDebugCoverageReportgradlew connectedCheck以获得jacoco覆盖率报告。

您可以在build/reports/coverage/{buildType}找到您的覆盖率报告。 (即为调试版本build/reports/coverage/debug

(从@ odiggity的评论中添加多种风味的情况)

如果您的项目使用多风格配置,请改用create{flavorName}CoverageReport 。 覆盖报告将在build/reports/coverage/{flavorName}/{buildType}

具有调试版本类型的风味krInternal的示例:

  • 命令: ./gradlew createKrInternalDebugCoverageReport
  • 报告详述如下: build/reports/coverage/krInternal/debug

小费 :

由于您只能使用device with root permissionemulatordevice with root permission获取覆盖率报告,因此在常规(无根)设备上运行命令后会出现以下错误:

05:48:33 E/Device: Error during Sync: Permission denied                         
java.io.IOException: com.android.ddmlib.SyncException: Permission denied
    at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:114)
    at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:158)
    at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:42)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)   
Caused by: com.android.ddmlib.SyncException: Permission denied
    at com.android.ddmlib.SyncService.doPullFile(SyncService.java:511)
    at com.android.ddmlib.SyncService.pullFile(SyncService.java:320)
    at com.android.ddmlib.Device.pullFile(Device.java:849)
    at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:107)
    ... 10 more                
:myDirections:connectedAndroidTest FAILED      

FAILURE: Build failed with an exception.

Over the hundreds of times searching the answer to getting a coverage report, I finally found an exact answer what I want.

From the this blog post, I found that gradlew createDebugCoverageReport creates the jacoco coverage report.

Also, from the gradle plugin source code, the plugin uses jacoco 0.6.2.201302030002 by default. (therefore, jacoco version definition is not required if you are going to use a default version)

In summary, the ESSENTIAL steps to get a jacoco coverage report with Android gradle plugin are:

  1. Android gradle plugin version 0.10.0 or higher (typically in your project's build.gradle)
  2. add testCoverageEnabled true to the build type you want (i.e. debug)
  3. run $ gradlew createDebugCoverageReport or gradlew connectedCheck to get a jacoco coverage report.

You can find your coverage report at the build/reports/coverage/{buildType}. (i.e. build/reports/coverage/debug for debug build)

(Add multi-flavor case from @odiggity's comment)

If your project uses multi-flavor configuration, use create{flavorName}CoverageReport instead. The coverage report will be generated at build/reports/coverage/{flavorName}/{buildType}.

Example for flavor krInternal with debug build type:

  • Command: ./gradlew createKrInternalDebugCoverageReport
  • Report is genarated at: build/reports/coverage/krInternal/debug

Tip :

Since you can only get a coverage report with the emulator and device with root permission, you'll get following error after running a command on the regular(non-rooted) device:

05:48:33 E/Device: Error during Sync: Permission denied                         
java.io.IOException: com.android.ddmlib.SyncException: Permission denied
    at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:114)
    at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:158)
    at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:42)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)   
Caused by: com.android.ddmlib.SyncException: Permission denied
    at com.android.ddmlib.SyncService.doPullFile(SyncService.java:511)
    at com.android.ddmlib.SyncService.pullFile(SyncService.java:320)
    at com.android.ddmlib.Device.pullFile(Device.java:849)
    at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:107)
    ... 10 more                
:myDirections:connectedAndroidTest FAILED      

FAILURE: Build failed with an exception.

Travis-CI build script to get code coverage

Include this block in build.gradle, for all modules (library, sample, etc)

android {
    lintOptions {
        abortOnError false
    }
}

Below is the .travis-ci.yml file

language: android
jdk: oraclejdk8
sudo: required

android:
  components:
  # Uncomment the lines below if you want to
  # use the latest revision of Android SDK Tools
  - tools
  - platform-tools
  # The BuildTools version used by your project
  - build-tools-28.0.3
  # The SDK version used to compile your project
  - android-28
  - android-22
  - add-on
  # Additional components
  - extra-google-google_play_services
  - extra-android-support
  - extra-google-m2repository
  - extra-android-m2repository
  # Specify at least one system image,
  # if you need to run emulator(s) during your tests
  - sys-img-armeabi-v7a-android-22

  licenses:
  - 'android-sdk-preview-license-52d11cd2'
  - 'android-sdk-license-.+'
  - 'google-gdk-license-.+'

before_cache:
- rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
    - $HOME/.android/build-cache

before_install:
- yes | sdkmanager "build-tools;28.0.3"

before_script:
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a -c 100M
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- sleep 180
- adb devices
- adb shell input keyevent 82 &

script:
- ./gradlew build connectedCheck

after_success:
- bash <(curl -s https://codecov.io/bash)

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)