空白屏幕 google 映射到 UI 测试 xamarin android

Blank screen google maps on UI test xamarin android

我为 Xamarin Forms 项目编写 Ui 测试,在 iOS 上使用 google 映射它们工作正常,但在 android 上仅显示空白屏幕。 如果基于调试/发布或安装 apk 映射工作,但如果我使用 UI 则什么都不测试。我使用 Nunit 2.6.4 并在本地设备、模拟器和 AppCenter 上进行测试。

为什么存在这个问题

当您编译包含 Google 地图的 .apk 时,地图会使用您的密钥库设置来验证地图是否合法(我不记得手边的确切细节,但基本上 - 如果用于签署 .apk 更改的密钥库信息 - 它破坏了映射)。

默认情况下,当您在不发送密钥库信息的情况下使用 UITest 时 - UITest 使用其自己的密钥库执行各种神奇的操作。这会导致地图停止工作。

如何在本地解决此问题

要在本地修复测试 运行,您需要告诉 UITest 使用您最初用于构建 .apk 文件的密钥库:

public AndroidAppConfigurator KeyStore (String path, String storePassword, String keyPassword, String keyAlias)

是您在设置应用程序配置时要使用的方法:

ConfigureApp
   .Android
   .ApkFile("path/to/my.apk")
   .Keystore(path, password, alias)
   .StartApp(mode);

如何在 App Center 中解决此问题

如果您想将测试发送到 App Center,那么您还需要做一件事 - 那就是在使用以下参数调用 appcenter-cli 时包含密钥库信息(您可以从 appcenter test run uitest --help:

   --key-password <arg>                 Password to the matching private  
                                        key in the keystore. Corresponds  
                                        to the "-keypass" argument in     
                                        jarsigner                         
   --key-alias <arg>                    Alias to the key in the keystore. 
                                        Corresponds to the "-alias"       
                                        argument in jarsigner             
   --store-password <arg>               Password to the keystore.         
                                        Corresponds to the "-storepass"   
                                        argument in jarsigner             
   --store-path <arg>                   Path to the keystore file

P.S。如果您在使用 App Center 时遇到问题 - 我建议使用网站底部角落的 Intercom 小部件打开对话 - 这会让您转接到测试支持团队,他们应该能够帮助您(您甚至可能得到跟我说话!:))