1
votes

I have three separate apps in which I am trying to create automated UI Tests. All three apps are written in Xamarin Forms, all three of these apps run in AppCenter's test cloud, and two of these apps will execute on devices and simulators locally.

However, one of these apps will not run tests locally, which makes it a bear to try to write tests around it. This is true for both iOS and Android, both on a device or on a simulator/emulator.

In all three apps, I have an interface that wraps an instance of IApp, which is passed into an implementation for iOS, and an implementation for Android, depending on the platform in which the tests are running.

To set up the instance of IApp, I am doing the following (this is also true for all three apps):

      switch (platform)
      {
        case Platform.Android:
          _app = ConfigureApp
            .Android
            .EnableLocalScreenshots()
            ?.StartApp();
          break;
        case Platform.iOS:
          _app = ConfigureApp
            .iOS
            .EnableLocalScreenshots()
            ?.StartApp();
          break;
        default:
          throw new ArgumentOutOfRangeException(nameof(platform), platform, null);
      }

However with one of these apps, attempts to run the UI Tests against an iOS Simulator ALWAYS fails with OneTimeSetUp: System.Exception : Must have either installed app or app bundle. and any attempt to run the UI Tests against an Android Emulator ALWAYS fails with OneTimeSetUp: System.Exception : ApkFile or InstalledApp has not been configured.

I have tried passing in the AppBundle to run on a simulator/emulator, and specifying an app identifier to run on a device. After several days, I am pretty well stumped.

Third party dependencies are as follows (these are true in all three apps):

NUnit 3.12.0
NUnitTestAdapter 2.2.0
Xamarin.UITest 3.0.3 (or 3.0.4-dev4 if I want to run against iOS 13)

As far as I can tell, all three apps have identical setup in terms of the UI Tests, but one does not run locally. What other things should I be looking for?

Visual Studio for Mac 8.3.5 (build 13)
xCode 11.1
Mono 6.4.0.208
Xamarin Android 10.0.3.0
Xamarin iOS 13.4.0.2
Mac OSX 10.14.6
1
That's odd. I would look for any unexpected differences in the UITest projects' .csproj files between the working and non-working UITest projects, and perhaps even the platform app projects' .csproj files as well. You might also try uninstalling the non-working app from the simulator/device. If already not installed, then you might try deploying the app for debugging normally. Otherwise, you can reach out to App Center support for help with Xam.UITest: intercom.help/appcenter/en/articles/…jgoldberger - MSFT

1 Answers

1
votes

So the issue here appeared to be that the UI Test was not referencing the iOS and Android projects at all. To make matters a little more confusing, in VS for Mac, I was unable to add the project references because they had incompatible target frameworks. It wasn't until I manually modified the csproj file to include these project references that this issue was resolved.

Thanks to @jgoldberger for the idea!