设置:System.Exception:尚未配置 ApkFile 或 InstalledApp

SetUp : System.Exception : ApkFile or InstalledApp has not been configured

我正在开发 xamarin 表单简单应用程序 (CreditCardValidator) 我从 [https://developer.xamarin.com/samples/test-cloud/Quickstarts/CreditCardValidator.Droid/]

下载了该应用程序

现在是否可以在不提供(.apk 文件)路径的情况下启动 运行 测试方法...如果不能,我想知道如何在 运行 测试方法之后启动 VS 模拟器(运行 自动启动 VS 模拟器的测试方法)?

public class Tests
{
    AndroidApp app;

    [SetUp]
    public void BeforeEachTest()
    {
        app = ConfigureApp.Android.StartApp();
    }

    [Test]
    public void CreditCardNumber_TooShort_DisplayErrorMessage()
    {
        app.WaitForElement(c => c.Marked("action_bar_title").Text("Enter Credit Card Number"));
        app.EnterText(c=>c.Marked("creditCardNumberText"), new string('9', 15));
        app.Tap(c => c.Marked("validateButton"));

        app.WaitForElement(c => c.Marked("errorMessagesText").Text("Credit card number is too short."));
    }
}

If there is only one device attached to the computer, and no running simulators, then UITest will automatically run the tests on the device.

这也适用于模拟器,因为它必须已经启动并且 运行。

来源: https://developer.xamarin.com/guides/testcloud/uitest/working-with/testing-on-devices/android/#Programmatically_Declaring_the_Device

但是由于您可能需要启动模拟器,您可以执行以下操作:

您可以使用一个名为 emulatorcmd.exe 的工具。它位于 Windows 的以下目录中:

C:\Program Files (x86)\Microsoft Emulator Manager.0

您可以使用 emulatorcmd.exe list /sku:Android /type:device /state:installed 获取已安装的可用模拟器列表。

然后您可以使用 emulatorcmd.exe launch /sku:Android /id:<id> 来启动特定的模拟器。

https://blogs.msdn.microsoft.com/visualstudioalm/2014/11/12/introducing-visual-studios-emulator-for-android/