How to use ConfigureApp when testing

I have written a simple test for an Android application. At the moment the visual studio solution contains no reference to the app.
But I can test the app (on a connected device) using the following:

public void BeforeEachTest()
    {
        app = ConfigureApp
            .Android
            .ApkFile(@"d:\xamarin\My.Sandbox.Android.apk")
            .DeviceSerial("123456789")
            .PreferIdeSettings()
            .StartApp();
    } 

But is there another way of specifying the application other than using ".AppFile"??
I know I can add the app project to my solution and use ".InstalledApp" to run the test - but the app must be installed first.
And I cant use ".ApkFile" when testing in the cloud either - as it refers to a local file.

So I'm looking for a way to test locally & in the cloud without having to refer to a specific apk file?
Any ideas?

Sean

Best Answer

  • SeanConlonSeanConlon US ✭✭
    Accepted Answer

    The solution is simple. I adjusted the code as follows:

    public void BeforeEachTest()
    {
            app = ConfigureApp
                .Android
                .PreferIdeSettings()
                .InstalledApp("My.Sandbox.Android")
                .StartApp();
    } 
    

    Whatever app I decide to upload will be installed automatically before testing. So all I need to do is refer to the already installed app in my test.

Answers

  • LakshmiNarayanaALakshmiNarayanaA USMember ✭✭
    Any updates on this context?
    I'm trying to create tests for activity/ context .
  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    Ah! this is very interesting question. I am yet to launch my tests in Test Cloud, so I may not be really helpful. There was no mention of how to set the .ApkFile or .Appbundle properties. But I have seen many examples specifying the final packages for testing using directory paths relative to current UITest project as "../../../".

    So I am assuming that specifying the '3 times backing up' should work.

    Also there some Channel 9 videos available on testing in Test Cloud.

  • SeanConlonSeanConlon USMember ✭✭
    Accepted Answer

    The solution is simple. I adjusted the code as follows:

    public void BeforeEachTest()
    {
            app = ConfigureApp
                .Android
                .PreferIdeSettings()
                .InstalledApp("My.Sandbox.Android")
                .StartApp();
    } 
    

    Whatever app I decide to upload will be installed automatically before testing. So all I need to do is refer to the already installed app in my test.

Sign In or Register to comment.