问题
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