[英]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.