Xamarin UiTest make some tests only executable on android or iOS?

481 Views Asked by At

I implemented UITest for the android version of an app and i am now trying to adapt the UI Tests code so it would work for both iOS and Android.

The thing is that there are really specific functions i've created for Android testing and they can't be used for iOS since the views are not concieved the same way at all.

Here are my questions:

-Is it possible to make certain test function executable only on iOS or Android (only one, not both) but within the same test.cs file ?

-What is the most conventional and clean way of organizing Ui Tests for Android or iOS?

  1. Same Project and same files for both platform("mySolution.UiTests" project and "Testfile.cs")
  2. Same Project different files for each platform ("mySolution.UiTests" project and "TestfileAndroid.cs" + "TestfileiOS.cs" )
  3. Different Projects for each platform ("mySolution.iOS.UiTests" and "mySolution.Droid.Uitests")
1

There are 1 best solutions below

0
On

I can give you an answer to the first question:

You can mark test fixtures with a platform attributle like this: [TestFixture(Platform.Android)] to be executed on android and [TestFixture(Platform.iOS)] to be executed on ios.

Provide both attributes above the class to make a test class executable on both platforms. I do not know if it is possbile for single tests too as I currently only needed it for whole classes.

So the useage could be like this

[TestFixture(Platform.Android)]
[TestFixture(Platform.iOS)]
public class FooTests
{ ... }

BR Hubertus