我想将 UnitTest 添加到我的 Xamarin 应用程序中,我在 Andriod 模拟器上显示初始屏幕,然后加载登录页面,但下一页似乎关闭了应用程序。我在 Platform.Android 周围有断点,并且它命中但它从未达到该方法的结尾。我添加了WaitTimes 5分钟,我会得到超时异常
知道应用程序关闭的原因吗?
static class AppManager
{
private const string ApkPath = @"C:\pathtoapkfile.apk";
static IApp app;
public static IApp App
{
get
{
if (app == null)
throw new NullReferenceException("'AppManager.App' not set. Call 'AppManager.StartApp()' before trying to access it.");
return app;
}
}
static Platform? platform;
public static Platform Platform
{
get
{
if (platform == null)
throw new NullReferenceException("'AppManager.Platform' not set.");
return platform.Value;
}
set { platform = value; }
}
public static void StartApp()
{
if (Platform == Platform.Android)
{
app = ConfigureApp
.Android
.ApkFile(ApkPath)
.WaitTimes(new WaitTimes())
.StartApp(AppDataMode.Clear);
}
if (Platform == Platform.iOS)
{
app = ConfigureApp
.iOS
.StartApp(AppDataMode.Clear);
}
}
}