Unmock Gradle 插件使用教程

Unmock Gradle 插件使用教程

unmock-pluginGradle plugin to be used in combination with the new unit testing feature of the Gradle Plugin / Android Studio to use real classes for e.g. SparseArray.项目地址:https://gitcode.com/gh_mirrors/un/unmock-plugin

1. 项目的目录结构及介绍

Unmock Gradle 插件的 GitHub 仓库地址为:bjoernQ/unmock-plugin。以下是该项目的目录结构及其介绍:

bjoernQ/unmock-plugin/
├── buildSrc/
├── example/
├── examplelib/
├── gradle/
│   └── wrapper/
├── .gitignore
├── LICENSE.txt
├── README.md
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
  • buildSrc/: 包含构建脚本的源代码。
  • example/: 示例项目,展示如何使用 Unmock 插件。
  • examplelib/: 示例库项目。
  • gradle/wrapper/: Gradle 包装器文件,确保使用特定版本的 Gradle。
  • .gitignore: Git 忽略文件配置。
  • LICENSE.txt: 项目许可证文件,采用 Apache-2.0 许可证。
  • README.md: 项目自述文件,包含项目的基本信息和使用说明。
  • build.gradle: 主构建脚本文件。
  • gradle.properties: Gradle 属性配置文件。
  • gradlew: Gradle 包装器脚本(Unix)。
  • gradlew.bat: Gradle 包装器脚本(Windows)。
  • settings.gradle: Gradle 设置文件,包含项目模块配置。

2. 项目的启动文件介绍

项目的启动文件主要是 build.gradlesettings.gradle

  • build.gradle: 这是主构建脚本文件,定义了项目的依赖、插件应用和其他构建配置。
  • settings.gradle: 这是 Gradle 设置文件,用于配置项目的模块和仓库。

3. 项目的配置文件介绍

  • gradle.properties: 这个文件用于配置 Gradle 构建系统的属性,例如 JVM 参数、构建缓存设置等。
  • build.gradle: 这个文件包含了项目的具体配置,例如插件应用、依赖管理、任务定义等。

以下是一个简单的 build.gradle 示例:

plugins {
    id 'com.android.application'
    id 'unmock'
}

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.example.unmock"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
}

unMock {
    keep "android.widget.BaseAdapter"
    keep "android.widget.ArrayAdapter"
    keepStartingWith "android.util."
}

在这个示例中,我们应用了 unmock 插件,并在 unMock 块中配置了需要保留的类和包。

通过以上配置,您可以开始使用 Unmock Gradle 插件来在单元测试中使用真实的 Android 类。

unmock-pluginGradle plugin to be used in combination with the new unit testing feature of the Gradle Plugin / Android Studio to use real classes for e.g. SparseArray.项目地址:https://gitcode.com/gh_mirrors/un/unmock-plugin

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贡锨庆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值