AppInitializer always launches android for cross platform tests

时间秒杀一切 提交于 2019-12-11 05:16:06

问题


I'm writing a UI Test that is supposed to be cross platform between Android and IOS.

When I run my App Initializer on a Mac, the "platform" Xamarin object always resolves as android (confirmed when running the tests in debug mode) even though I have an iOS simulator open and an iOS device plugged in with no Andorid simulators or devices connected.

public static IApp StartApp(Platform platform)
    {
        if (platform == Platform.Android)
        {
            return ConfigureApp
                .Android
                .ApkFile("../../Binaries/Android/com.xamarin.samples.taskyandroid.apk")
                .StartApp();
        }

        return ConfigureApp
            .iOS
            .AppBundle("../../Binaries/iOS/TaskyiOS.app")
            .DeviceIdentifier("Device id")
            .StartApp();
    }

The only time I can launch an iOS simulator is when I comment out the if condition without evaluating platform.

How can I get the appinitializer to detect iOS as the platform?

Thanks for your thoughts.


回答1:


Ensure that you are running your tests for the desired OS, from the Unit Tests (XS) or Test Explorer (VS) window

  • Xamarin Studio >> View >> Pads >> Unit Tests
  • Visual Studio >> Tests >> Test Explorer

I beleive platform will default to Android if you use the Play / Run button, while the UITest project is selected as the Startup Project, or if you use Run All (starting with Android since it appears before iOS)

(wow, that image is huge, sorry)



来源:https://stackoverflow.com/questions/37731970/appinitializer-always-launches-android-for-cross-platform-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!