1

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

Luis Beltran
  • 1,704
  • 12
  • 13
  • does your UI update somehow after the process has finished? – Sven-Michael Stübe Apr 11 '16 at 14:26
  • It actually does. Some values are calculated and shown in Labels. I even modified a Button's Text at the end of the long process. Local test (emulator) updates all the UI, while TestCloud does not, as it finishes the process in seconds. – Luis Beltran Apr 11 '16 at 16:58

3 Answers3

3

Something like this should do the job:

[Test]
public async void Optimize()
{
   app.Screenshot("Start");
   app.Tap("btnOptimize");
   app.WaitForElement ("otherButton", "Timed out waiting for Button", new TimeSpan(0,30,0));
   app.Screenshot("End");
}

Where "otherButton" becomes visible when the task is done. There are other Wait methods available in the API.

But, note that the Xamarin Test Cloud has a thirty minute maximum per test by default. That default can be modified by contacting Xamarin Test Cloud support.

Also, it is not a good practice to include non-deterministic information or any information that may vary per device or run in your screen shot titles. When you run on more than one device the test report steps and screenshots are collated partially by the screen shot titles so they should match across devices for best results.

Glenn Wilson
  • 241
  • 1
  • 8
1

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....

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
0

You need to identify tap by Id and add WaitForElement(first argument is query you want to wait on) in correct syntax like given below. It should work for you.

app.Screenshot("Start " + DateTime.Now); app.WaitForElement(x => x.Id("btnOptimize"),"Optimization timed out",new System.TimeSpan(0,30,0),null,null); app.Tap(x => x.Id("btnOptimize")); app.Screenshot("End " + DateTime.Now);