如何从持续集成服务器推送UI测试到App Center测试

时间:2018-03-25 00:38:24

标签: xamarin xamarin.android xamarin.uitest visual-studio-app-center visual-studio-app-center-test

如何从命令行将UI测试连同相关应用程序推送到App Center Test?

我使用CI(持续集成)服务器来构建我的应用程序,我尝试使用App Center测试门户网站提供的以下命令,但它不起作用并输出错误,下面:

<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 26 14" xmlns="http://www.w3.org/2000/svg">
    <rect width="2" height="2"/>
    <rect x="4" width="2" height="2"/>
    <rect x="8" width="2" height="2"/>
    <rect x="12" width="2" height="2"/>
    <rect x="16" width="2" height="2"/>
    <rect x="20" width="2" height="2"/>
    <rect x="24" width="2" height="2"/>
    <rect x="24" y="4" width="2" height="2"/>
    <rect x="20" y="4" width="2" height="2"/>
    <rect x="16" y="4" width="2" height="2"/>
    <rect x="12" y="4" width="2" height="2"/>
    <rect x="8" y="4" width="2" height="2"/>
    <rect x="4" y="4" width="2" height="2"/>
    <rect y="4" width="2" height="2"/>
    <rect y="8" width="2" height="2"/>
    <rect x="4" y="8" width="2" height="2"/>
    <rect x="8" y="8" width="2" height="2"/>
    <rect x="12" y="8" width="2" height="2"/>
    <rect x="16" y="8" width="2" height="2"/>
    <rect x="20" y="8" width="2" height="2"/>
    <rect x="24" y="8" width="2" height="2"/>
    <rect x="24" y="12" width="2" height="2"/>
    <rect x="20" y="12" width="2" height="2"/>
    <rect x="16" y="12" width="2" height="2"/>
    <rect x="12" y="12" width="2" height="2"/>
    <rect x="8" y="12" width="2" height="2"/>
    <rect x="4" y="12" width="2" height="2"/>
    <rect y="12" width="2" height="2"/>
</svg>
  

命令&appcenter test运行uitest&#39;需要登录用户。使用&#39; appcenter登录&#39;命令登录

我正在尝试部署Xamarin.Android应用和Xamarin.UITest。

enter image description here

1 个答案:

答案 0 :(得分:3)

从CLI推送到App Center测试

1。手动检索API令牌

App Center CLI要求用户登录,我们可以通过提供登录令牌从我们的构建服务器登录。

使用App Center CLI,输入以下命令,将[Name Of Token]替换为您要为此令牌命名的任何内容

appcenter login
appcenter tokens create -d "[Name Of Token]"

它会提供这样的回复:

  

ID:[Unique Guid]

     

API令牌:[唯一API令牌]

     

描述:[令牌名称]

     

创建于:[时间戳]

复制API令牌结果。我们将在CI脚本中使用它。

2。 CI服务器的App Center测试脚本

在持续集成管道中,使用此bash脚本将APK文件+ UI测试推送到App Center测试

bash脚本执行以下操作:

  1. 找到UI测试构建目录
    • [My UI Test Assembly Name]替换为UI测试程序集的名称
  2. 找到APK文件
  3. 安装appcenter cli
  4. 使用API​​令牌登录App Center
  5. 将APK + UI测试推送至App Center测试
  6. #!/usr/bin/env bash
    
    UITestDLL=`find . -name "[My UI Test Assembly Name].dll" | grep bin`
    UITestBuildDir=`dirname $UITestDLL`
    
    APKFile=`find . -name *.apk | head -1`
    
    npm install -g appcenter-cli
    
    appcenter login --token [login token from Step 1]
    
    appcenter test run uitest --app "bminnick/uitestsampleapp" --devices b139e40f --app-path $APKFile --test-series "master" --locale "en_US" --build-dir $UITestBuildDir --async