简体   繁体   English

在 android 上跳过 Azure 管道特定任务的测试

[英]Skip test on android on specific task of Azure pipeline

I have an Android library project with two Unit test, and those tasks defined in the Gradle:我有一个带有两个单元测试的 Android 库项目,以及在 Gradle 中定义的那些任务:

task("cleanProject", dependsOn: "clean", group: "myGroup")

task("generateAAR", dependsOn: "assembleRelease", group: "myGroup")

task("copyAAR", type: Copy, group: "myGroup") {
    from "${project.rootDir}/project/build/outputs/aar"
    into "${project.rootDir}/mydir/aar"
}

and I tried to use Azure pipelines by adding the following .yml:我尝试通过添加以下 .yml 来使用 Azure 管道:

    - task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'cleanProject'
  displayName: Clean Project

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'testReleaseUnitTest'
  displayName: Release Unit Test

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'generateAAR'
  displayName: Generate AAR Lib

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'copyAAR'
  displayName: Copy AAR Lib

It works nicely, but I noticed that the test are performed also on generateAAR and copyAAR tasks, resulting in 6 total test passed.它工作得很好,但我注意到测试也在 generateAAR 和 copyAAR 任务上执行,结果总共通过了 6 个测试。 Is there a way to exclude the tests from a specific task or pipeline?有没有办法从特定任务或管道中排除测试?

Thanks in advance.提前致谢。

Is there a way to exclude the tests from a specific task or pipeline?有没有办法从特定任务或管道中排除测试?

Azure devops service itself doesn't have the option to exclude tests from one task.(test level) Instead it supports disabling/skipping task in pipeline.(task level) Azure devops 服务本身没有从一项任务中排除测试的选项。(测试级别)相反,它支持禁用/跳过管道中的任务。(任务级别)

Check gradle's skipping the tests and skipping the tasks , I think that's what you're looking for.检查 gradle's skipping the tests和 skips the tasks ,我认为这就是你要找的。

I know it has been a while, but maybe somebody find my answer useful, because there is a way to do it, at least it works for us in the project.我知道已经有一段时间了,但也许有人发现我的答案很有用,因为有一种方法可以做到,至少它在项目中对我们有用。 Gradle Task for azure has an "options" argument, see the official docs: azure 的 Gradle 任务有一个“选项”参数,请参阅官方文档:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/gradle?view=azure-devops https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/gradle?view=azure-devops

在此处输入图片说明

This means that your final solution will look sth like this:这意味着您的最终解决方案将如下所示:

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'generateAAR'
    options: '-x test -x integrationTest' // exclude both test and IT
  displayName: Generate AAR Lib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .apk 文件不是使用 azure 管道中的 xamarin.android 任务生成的 - .apk file not generated using xamarin-android task in azure pipeline 在 Android+Gradle 中跳过特定构建变体的测试? - Skip test for specific build variant in Android+Gradle? 如何跳过特定的gradle任务 - How to skip a specific gradle task Android:Skip Gradle“testClasses”任务用于依赖项目 - Android: Skip Gradle “testClasses” task for a dependency project 跳过特定构建类型的测试任务 - Skip test tasks for specific build types Android -gradle task -Azure devops - Pipeline No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi - Android -gradle task -Azure devops - Pipeline No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi 如何有条件地跳过 Android 和 kotlin 中的单元测试? - How to conditionally skip a unit test in Android and kotlin? Android 的自定义 Gradle 测试任务 - Custom Gradle Test Task For Android 如何在Android上测试Firebase任务? - How to test a Firebase task on Android? 跳过两者之间的活动并达到android中的特定活动 - Skip the activities in between and reach the specific activity in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM