Search code examples
androidgradleazure-pipelinesgradle-android-test-plugi

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:

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:

    - 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. Is there a way to exclude the tests from a specific task or pipeline?

Thanks in advance.


Solution

  • 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)

    Check gradle's skipping the tests and skipping the tasks, I think that's what you're looking for.