gpt4 book ai didi

c# - 为 Android 运行 Xamarin UI 测试时等待 ClearAppData2 的结果超时

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:49 25 4
gpt4 key购买 nike

我已经使用 Xamarin UITest 框架为我的 Xamarin 应用程序创建了自动 Android 和 iOS UI 测试。在本地运行测试时,它们运行良好,但在 Bitrise CI 上运行时,iOS 测试运行良好,但 Android UI 测试一直失败,出现以下异常:

StartFirstActivity_WaitForActivity_ExpectButtonToHaveText
SetUp : System.Exception : Timed out waiting for result of ClearAppData2
Stack trace:
at Xamarin.UITest.Shared.Android.Commands.CommandAdbClearAppData.Execute (IProcessRunner processRunner, IAndroidSdkTools androidSdkTools) <0x38b3e90 + 0x0064b> in <filename unknown>:0
at Xamarin.UITest.Shared.Execution.Executor.Execute[TDep1,TDep2] (ICommand2 command) <0x32b6478 + 0x00092> in <filename unknown>:0
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.EnsureInstalled (Xamarin.UITest.Shared.Android.ApkFile appApkFile, Xamarin.UITest.Shared.Android.ApkFile testServerApkFile) <0x37418c8 + 0x0017a> in <filename unknown>:0
at Xamarin.UITest.Android.AndroidApp..ctor (IAndroidAppConfiguration appConfiguration) <0x31a15e8 + 0x0047a> in <filename unknown>:0
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp (AppDataMode appDataMode) <0x30b4298 + 0x00063> in <filename unknown>:0
at SightPlayer.Core.Test.AppInitializer.StartApp (Platform platform) <0x30b2448 + 0x000ef> in <filename unknown>:0
at SightPlayer.Core.Test.Tests.BeforeEachTest () <0x30b23f8 + 0x00013> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x30b2208 + 0x00093> in <filename unknown>:0

Android 测试使用 Xamarin.UITest 版本 1.3.5 运行。这很重要,因为似乎有一个 bug until version 1.3.3 .我也试过忽略失败的测试,但随后测试运行器因其他 Android 测试而失败。有趣的是,有时个别测试会通过。

有没有人遇到过这种行为?您对如何解决这个问题有什么建议吗?

在反编译 CommandAdbClearAppData(抛出异常)时,我看到了

// ISSUE: reference to a compiler-generated field
string str1 = string.Format("/data/data/{0}/files/calabash_failure.out", (object)executeCAnonStorey0.svr);
// ISSUE: reference to a compiler-generated field
string str2 = string.Format("/data/data/{0}/files/calabash_finished.out", (object)executeCAnonStorey0.svr);
while (DateTime.UtcNow < utcNow + TimeSpan.FromSeconds(10.0))
{
if (func(string.Format("ls {0}", (object)str1)).Output.Trim().Equals(str1))
throw new Exception("Clear app data failed with " + func(string.Format("cat {0}", (object)str1)).Output);
if (func(string.Format("ls {0}", (object)str2)).Output.Trim().Equals(str2) && func(string.Format("cat {0}", (object)str2)).Output.Trim().Equals("SUCCESSFUL"))
return;
}
throw new Exception("Timed out waiting for result of ClearAppData2");

表示在十秒内找不到生成的文件。会不会是模拟器太慢了,模拟器创建这些文件需要超过 10 秒的时间?

最佳答案

Could it be, that the emulator is simply too slow and the emulator takes longer than ten seconds to create those files?

是的,这可能是问题所在。

Do you have any advice on how to fix this?

Xamarin.UITest nuget 包的最新开发版本已将该超时间隔从 10 秒增加到 60 秒。

尝试 Xamarin.UITest 1.3.6.1476-dev或更新版本。

关于c# - 为 Android 运行 Xamarin UI 测试时等待 ClearAppData2 的结果超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36389383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com