使用 AzureDevOps 构建和上传浓缩咖啡测试到 Browserstack



我正在关注如何在Browserstack上运行自动浓缩咖啡测试的链接。我想使用我创建的azure管道将上面提到的所需APK上传到Browserstack。我已经成功地构建并上传了我的应用程序的APK,正如你在下面的.yaml文件中看到的那样,但我不知道如何通过azure为我的测试类生成测试APK,以便将其上传到BrowserStack。上面的指南提到了上传测试套件,它们是指在构建和运行测试类文件时生成的APK吗?如果是这样的话,我不需要通过azure更改构建配置,然后重新构建吗?

pool:
vmImage: ubuntu-latest
# build apk
- task: Gradle@2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'assembleDebug'
# retain the apk artifact
- task: CopyFiles@2
inputs:
contents: '**/*.apk'
targetFolder: '$(build.artifactStagingDirectory)'
- task: BrowserStackConfig@0
inputs:
BrowserStackServiceEndPoint: 'BrowserStack connection'
# Upload apk to BrowserStack
- task: BrowserStackAppUploader@0
inputs:
appPath: '/my/path/debug/presentation-google-debug.apk'
appCustomId: 'myID'
displayName: 'Uploading apk to BrowserStack'
# build and upload test apk here
# post test results
- task: BrowserStackResults@0

您需要根据设置添加构建测试套件APK的步骤。

为了上传测试套件并触发测试,您可以使用以下内容:

- script: |
echo "upload test suite"
curl -u "username:access_key" 
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/test-suite" 
-F "file=@/path/to/app/file/Application-debug-test.apk" 
-F "custom_id=SampleTest"

echo "triggering test" 

curl -u "username:access_key" 
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" 
-d '{"app": "myID", "testSuite": "SampleTest", "devices": ["Samsung Galaxy S9 Plus-9.0"]}' 
-H "Content-Type: application/json" 
displayName: 'uploading test suite and triggering test'

最新更新