I'm trying to write automated tests using Xamarin UI Test, within certain parts of those tests I need to know which platform they are running on i.e. Android or iOS.
I'm struggling to find a way of doing this, does anyone know of an API to do this or any other such trick?
Your tests class have a constructor like this:
[TestFixture(Platform.Android)]
[TestFixture(Platform.iOS)]
public class Tests
{
IApp app;
Platform platform;
public Tests(Platform platform)
{
this.platform = platform;
}
[SetUp]
public void BeforeEachTest()
{
app = AppInitializer.StartApp(platform);
}
}
Later on, in you test method you could do this:
[Test]
public void MyTest()
{
if (platform == Platform.Android)
{
// Do specific code here.
}
}