xamarinxamarin-test-cloud

Testing a long process in Xamarin Test Cloud


I have a question about Xamarin Test Cloud, hope someone can point me in the right direction.

When a user taps a button in my app, a process runs for around 30 minutes. I added a Unit Test project and it runs perfectly in the emulator.

However, I need to test it in real devices, so I decided to use Xamarin Test Cloud. When I run the test there, it doesn't complete it. As I said, it should take 30 minutes but the test finishes almost immediately.

Here is the code of my Test:

[Test]
[Timeout(Int32.MaxValue)]
public async void Optimize()
{
 await Task.Run(async() =>
 {
   app.Screenshot("Start " + DateTime.Now);
   app.Tap(x => x.Marked("btnOptimize"));
   await Task.Delay(120000);
   app.Screenshot("End " + DateTime.Now);
 }
}

If I run the test in the emulator, the screenshot names are (for instance) "Start 12:00:00" and "End 12:30:00" respectively (so it means that it runs for 30 minutes, as expected). However, in Test Cloud I get (for instance) "Start 12:00:00" and "End 12:02:00", which means that the test runs for only 2 minutes. But that's because I added the delay. Without the delay, it will run for only 5 seconds.

Is that what I need? I can add 1800000 so the test can be completed in 30 minutes, but what if I don't know the time?

Thank you and sorry if it's a basic question


Solution

  • While I have never tried a timeout length of 30 minutes, the Calabash allows you to wait for a condition using wait_for):

    The following snippet is an example of how to use wait_for to detect the presence of a button on the screen:

    wait_for(timeout: 60, timeout_message: "Could not find 'Sign in' button") do
        element_exists("button marked:'Sign in'")
    end
    

    Ref: https://docs.xamarin.com/guides/testcloud/calabash/working-with/timeouts/

    Just an FYI: 30 minutes is a really long time for a mobile device to be "background processing" without user interface interaction, if you are targeting iOS/Apple Store, this death sentence in getting Apple submission approval as they will never wait that long for an app to process something....