AppInitializer always launches android for cross p

2019-07-25 21:07发布

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条回答
我命由我不由天
2楼-- · 2019-07-25 21:46

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) image

查看更多
登录 后发表回答