In the first blog of our Xamarin.UITest 101 series, we have covered how to set up the Xamarin development environment with Visual Studio on Windows 10, today we will set up a development environment for Apple’s macOS and go through running Xamarin.UITest tests on Android and iOS platforms.
Setting Up Xamarin Environment on macOS
Let’s first set up the macOS environment by installing Visual Studio for Mac.
We can go to https://visualstudio.microsoft.com/vs/mac/ and download Visual Studio for Mac.
After downloading and installing the Visual Studio for Mac development environment, we will be prompted with options for installation.
Select Android and iOS in the Targets section, and click the Install and Update (if any updates) button.
Creating a New Project on Visual Studio for Mac
After the installation is completed, we will see a dialogue box with the options to open or create a new project.
Since we have already created a cross-platform Xamarin.Forms app and a sample test of it with Xamarin.UITest in the previous blog, it’s very easy to take the project code to the macOS machine.
Open the project with Visual Studio for Mac.
After the project is built, we can install our Xamarin.Forms app on the Android device.
And then, we can run our Xamarin.UITest tests against the Android device.
To launch the app on the Xamarin iOS platform, we need to change our development environment to the necessary configuration of ATXamarin.iOS. Also, we should uncomment the [TestFixture(Platform.iOS)] platform.
To install the application, we need to select the simulator (where the app will be installed and launched) and click on the Play button.
In our case, we will choose the simulator of the iPhone 11 (iOS 13.3).
To run Xamarin.UITest tests, we need to change the configuration of the AppInitializer.cs class.
For this, we have to take a path to the app in the AppBundle method. The path should be specified relative to the folder with our test.
Obviously, we have to specify the identifier of our simulator too.
In order to get this identifier, we can use the following command:
xcrun instruments -s devices
We need the identifier of the iPhone 11 (iOS 13.3).
After we enter all the necessary data, we can run our tests. But at this stage, there can be an error with the customization of Calabash components.
We need to install Xamarin Test Cloud Agent for the ATXamarin.iOS project.
After the package is added, we have to enter the following code block in the AppDelegate.cs class:
#if ENABLE_TEST_CLOUD Xamarin.Calabash.Start(); #endif
After this, we can run Xamarin.UITest tests on the iOS simulator.
When the test is completed, we will see a newly created item (similar to the one created after a test run on the Android device).
The post Running Xamarin.UITest Tests on Different Mobile OS appeared first on Bitbar.
This post first appeared on Mobile App Testing Blog, With Games And Web | Test, please read the originial post: here