培训
认证
Microsoft Certified: Power Automate RPA Developer Associate - Certifications
演示如何与 Microsoft Power Automate RPA 开发人员一起改进和自动化工作流。
重要
Visual Studio App Center 计划于 2025 年 3 月 31 日停用。 虽然可以继续使用 Visual Studio App Center,直到它完全停用,但有几种建议的替代方法可以考虑迁移到其中。
此示例演示如何使用 API 上传应用包、测试二进制文件和队列 UI 测试。
示例请求 https://api.appcenter.ms/v0.1/apps/MSKASANI/DroidAppSampleXamarin/test_runs
可以通过运行命令 shasum
来获取文件哈希。 默认情况下,此实用工具在 Mac/Linux 计算机中可用。 对于 Windows,请考虑安装 Git Bash 并改用它。
示例
ankasani@AK--PC MINGW64 ~/source/repos/AppXamarin/sampleapp-xamarin-master/UITest/bin/Debug/testdlls (master)
$ shasum nunit.framework.dll
a2d0dbc920fb3790d4d625e5c47be042ca32c051 *nunit.framework.dll
$ shasum Xamarin.UITest.dll
c1f7342d05a9d95580a507156207e6f9283a2c8d *Xamarin.UITest.dll
$ shasum UITest.dll
542153902bc889d0d85a83b005854b5ebd9864f1 *UITest.dll
$ shasum com.mobilecenter.sampleappxamarin.apk
3f3677f8db9ba7c07ac77d4f01f912e518a6ca16 *com.mobilecenter.sampleappxamarin.apk
示例请求https://api.appcenter.ms/v0.1/apps/MSKASANI/DroidAppSampleXamarin/test_runs/fb0cc373-aa4a-455f-b083-4fc1afa87f2e/hashes/batch
file_type - apk\ipa 的 app-file 和测试程序集/测试相关文件的测试文件。
校验和 - 步骤 2 中的哈希值
relative_path - 可以使用扩展名定义文件名,无需指定完整路径。
JSON 正文如下所示:
[
{
"file_type":"app-file",
"checksum":"3f3677f8db9ba7c07ac77d4f01f912e518a6ca16",
"relative_path":"com.mobilecenter.sampleappxamarin.apk"
},
{
"file_type":"test-file",
"checksum":"a2d0dbc920fb3790d4d625e5c47be042ca32c051",
"relative_path":"nunit.framework.dll"
},
{
"file_type":"test-file",
"checksum":"c1f7342d05a9d95580a507156207e6f9283a2c8d",
"relative_path":"Xamarin.UITest.dll"
},
{
"file_type":"test-file",
"checksum":"542153902bc889d0d85a83b005854b5ebd9864f1",
"relative_path":"UITest.dll"
}
]
响应如下所示:
[
{
"fileType": "app-file",
"checksum": "3f3677f8db9ba7c07ac77d4f01f912e518a6ca16",
"relativePath": "com.mobilecenter.sampleappxamarin.apk",
"uploadStatus":
{
"statusCode": 412,
"location": "https://testcloud.xamarin.com/v0.1/direct_uploads?token=ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKU1V6STFOaUo5LmV5SjBaWE4w%0AWDNKMWJsOXBaQ0k2SWpjNU5EVmpNbUZtTFRFeFpXTXROR1ptWVMwNU1XSTBM%0AVFExTUdJd09EVTNNbU5sT1NJc0ltVjRjQ0k2TVRVek16Z3dOVFEzTUgwLlJO%0AaTQ3VTNPYTB5YWswMVRVdTV6Q0dfWFhwV25QUWJDdkJaNmVCRWRmOENuQ19U%0AbmdpRGI4MU0yYk1lTlZNY1VCVmRWLXlkRjh4dElLaU1yNFdtQUFhOFdoay02%0AOVVjb29rYkNTYUU2eUlzamowZlZPZVJhR2lFdGpvLWJHTFJLcXNGY0ZTeUdR%0ARTQzQUZ1TFlyTWlCRnowMElpd3ZudjYzZk9wQnRGaXhNa2lNNjhUTWxxVnNa%0AOFl3TFlTeU5KSWFvYVJCM0ZZTUkwajNYOWdVb3VJclVjNnpqcGNkYkxCcWJ0%0AVUpyN0ZFaTdJeWY4UG9rMXZxTzRlUExiaEszTmItTmd0Q2JuckZzS2x6Z3Za%0AaktUWHZZb2oya0FGWXZHaVZ4LVhfNVhUcGdiVnE1Z2dxVEtIdjRaUGFuaGR4%0AdnFvZ2YxRVYwWUJYaG40YUJLM3BnUVBodw%3D%3D%0A"
}
},
{
"fileType": "test-file",
"checksum": "a2d0dbc920fb3790d4d625e5c47be042ca32c051",
"relativePath": "nunit.framework.dll",
"uploadStatus":
{
"statusCode": 412,
"location": "https://testcloud.xamarin.com/v0.1/direct_uploads?token=ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKU1V6STFOaUo5LmV5SjBaWE4w%0AWDNKMWJsOXBaQ0k2SWpjNU5EVmpNbUZtTFRFeFpXTXROR1ptWVMwNU1XSTBM%0AVFExTUdJd09EVTNNbU5sT1NJc0ltVjRjQ0k2TVRVek16Z3dOVFEzTUgwLlJO%0AaTQ3VTNPYTB5YWswMVRVdTV6Q0dfWFhwV25QUWJDdkJaNmVCRWRmOENuQ19U%0AbmdpRGI4MU0yYk1lTlZNY1VCVmRWLXlkRjh4dElLaU1yNFdtQUFhOFdoay02%0AOVVjb29rYkNTYUU2eUlzamowZlZPZVJhR2lFdGpvLWJHTFJLcXNGY0ZTeUdR%0ARTQzQUZ1TFlyTWlCRnowMElpd3ZudjYzZk9wQnRGaXhNa2lNNjhUTWxxVnNa%0AOFl3TFlTeU5KSWFvYVJCM0ZZTUkwajNYOWdVb3VJclVjNnpqcGNkYkxCcWJ0%0AVUpyN0ZFaTdJeWY4UG9rMXZxTzRlUExiaEszTmItTmd0Q2JuckZzS2x6Z3Za%0AaktUWHZZb2oya0FGWXZHaVZ4LVhfNVhUcGdiVnE1Z2dxVEtIdjRaUGFuaGR4%0AdnFvZ2YxRVYwWUJYaG40YUJLM3BnUVBodw%3D%3D%0A"
}
},
{
"fileType": "test-file",
"checksum": "c1f7342d05a9d95580a507156207e6f9283a2c8d",
"relativePath": "Xamarin.UITest.dll",
"uploadStatus":
{
"statusCode": 412,
"location": "https://testcloud.xamarin.com/v0.1/direct_uploads?token=ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKU1V6STFOaUo5LmV5SjBaWE4w%0AWDNKMWJsOXBaQ0k2SWpjNU5EVmpNbUZtTFRFeFpXTXROR1ptWVMwNU1XSTBM%0AVFExTUdJd09EVTNNbU5sT1NJc0ltVjRjQ0k2TVRVek16Z3dOVFEzTUgwLlJO%0AaTQ3VTNPYTB5YWswMVRVdTV6Q0dfWFhwV25QUWJDdkJaNmVCRWRmOENuQ19U%0AbmdpRGI4MU0yYk1lTlZNY1VCVmRWLXlkRjh4dElLaU1yNFdtQUFhOFdoay02%0AOVVjb29rYkNTYUU2eUlzamowZlZPZVJhR2lFdGpvLWJHTFJLcXNGY0ZTeUdR%0ARTQzQUZ1TFlyTWlCRnowMElpd3ZudjYzZk9wQnRGaXhNa2lNNjhUTWxxVnNa%0AOFl3TFlTeU5KSWFvYVJCM0ZZTUkwajNYOWdVb3VJclVjNnpqcGNkYkxCcWJ0%0AVUpyN0ZFaTdJeWY4UG9rMXZxTzRlUExiaEszTmItTmd0Q2JuckZzS2x6Z3Za%0AaktUWHZZb2oya0FGWXZHaVZ4LVhfNVhUcGdiVnE1Z2dxVEtIdjRaUGFuaGR4%0AdnFvZ2YxRVYwWUJYaG40YUJLM3BnUVBodw%3D%3D%0A"
}
},
{
"fileType": "test-file",
"checksum": "542153902bc889d0d85a83b005854b5ebd9864f1",
"relativePath": "UITest.dll",
"uploadStatus":
{
"statusCode": 412,
"location": "https://testcloud.xamarin.com/v0.1/direct_uploads?token=ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKU1V6STFOaUo5LmV5SjBaWE4w%0AWDNKMWJsOXBaQ0k2SWpjNU5EVmpNbUZtTFRFeFpXTXROR1ptWVMwNU1XSTBM%0AVFExTUdJd09EVTNNbU5sT1NJc0ltVjRjQ0k2TVRVek16Z3dOVFEzTUgwLlJO%0AaTQ3VTNPYTB5YWswMVRVdTV6Q0dfWFhwV25QUWJDdkJaNmVCRWRmOENuQ19U%0AbmdpRGI4MU0yYk1lTlZNY1VCVmRWLXlkRjh4dElLaU1yNFdtQUFhOFdoay02%0AOVVjb29rYkNTYUU2eUlzamowZlZPZVJhR2lFdGpvLWJHTFJLcXNGY0ZTeUdR%0ARTQzQUZ1TFlyTWlCRnowMElpd3ZudjYzZk9wQnRGaXhNa2lNNjhUTWxxVnNa%0AOFl3TFlTeU5KSWFvYVJCM0ZZTUkwajNYOWdVb3VJclVjNnpqcGNkYkxCcWJ0%0AVUpyN0ZFaTdJeWY4UG9rMXZxTzRlUExiaEszTmItTmd0Q2JuckZzS2x6Z3Za%0AaktUWHZZb2oya0FGWXZHaVZ4LVhfNVhUcGdiVnE1Z2dxVEtIdjRaUGFuaGR4%0AdnFvZ2YxRVYwWUJYaG40YUJLM3BnUVBodw%3D%3D%0A"
}
}
]
现在我们需要 上传 实际文件。
在上一个响应正文中,标识 location
包含要上传的文件的 URL。
relative_path
和 file_type
:来自上一个响应正文file
:实际文件的路径如果收到 201 Created
响应,请进入正确的轨道,如下所示。
(我们中间有一半)
对要上传的其余文件重复上一步。
现在可以执行测试了。 为此,我们需要一个device_slug。
注意:应首先在组织中创建“设备集”,也可以使用 REST API 创建设备集。
然后,可以使用 GET 方法获取 设备集的列表。
示例请求:https://api.appcenter.ms/v0.1/apps/MSKASANI/DroidAppSampleXamarin/owner/device_sets
相应的响应正文:
{
"id": "00917fb6-f30f-4d36-bd53-f900a94efe9f",
"name": "UI Test",
"slug": "ui-test",
"osVersionCount": 1,
"manufacturerCount": 1,
"owner":
{
"type": "organization",
"id": "5dd75115-3832-4f10-9cfe-5ac8cc8a51a5",
"displayName": "MSKASANI",
"name": "MSKASANI"
},
"deviceConfigurations":
{
{
"id": "717cfc38-4817-41fc-8a8e-06beef4f73b2",
"image":
{
"thumb": "https://testcloud-prod-system-files.s3-eu-west-1.amazonaws.com/system_files/0dee6ee7-6839-4e4e-ad0b-333e3952f75c?response-cache-control=max-age%3D157788000&AWSAccessKeyId=AKIAI4UZT4FCOF2OTJYQ&Signature=r9EEm/x0YAA4NhRJ%2BhVSQwGtBbI%3D&Expires=1691079085"
},
"os": "8.1.0",
"osName": "Android 8.1.0",
"model":
{
"name": "Google Pixel 2 XL",
"manufacturer": "Google",
"releaseDate": "October 2017",
"formFactor": "phone"
}
}
}
}
示例 JSON 请求正文:
{
"test_framework":"ui_test",
"device_selection":"MSKASANI/ui-test",
"locale":"en_US",
"test_series":"apimain",
"test_parameters":
{
"tests":
{
"method":
{
"UITest.dll":
[
"UITest.Tests(Android).AppLaunches",
"UITest.Tests(iOS).AppLaunches"
]
},
"fixture":
{
"UITest.dll":
[
"UITest.Tests(Android)",
"UITest.Tests(iOS)"
]
}
}
}
}
相应的响应正文:
{
"accepted_devices":["Google Pixel 2 XL (8.1.0)"],
"rejected_devices":[]
}
如果现在转到 应用的“测试 ”页,你将看到...
祝贺你! :)
PS:对于其他测试框架,如果想要了解 JSON 的外观(例如,Appium 测试)
使用 --debug
开关手动运行 Test 命令。
appcenter 测试运行 appium --app “MSKASANI/Appium” --devices “MSKASANI/my” --app-path C:\VSAC\AllTest\AppCenter-Test-Samples-main\Appium\Android\swiftnote.apk --test-series “main” --locale “en_US” --build-dir C:\VSAC\AllTest\AppCenter-Test-Samples-main\Appium\Android\Mavenex\target\upload --debug
测试完成后,可以查看命令输出以查看请求正文的外观:
奖金! 这样,便可以使用 CLI 输出来了解命令如何使用 API 对测试进行排队!
培训
认证
Microsoft Certified: Power Automate RPA Developer Associate - Certifications
演示如何与 Microsoft Power Automate RPA 开发人员一起改进和自动化工作流。