Forum Xamarin Test Cloud (Read Only)

How can I setup local UI Tests automatically

I'm using Jenkins running locally on my network to build, restore packages, run unit tests etc. I would to run some UI tests too. Where should I start looking for some documentation on how to run UI Tests through the command line? Everything I've found so far is to run the tests on the Test Cloud.

Best Answer


  • mattwardmattward GBMember Xamurai
    edited May 2016

    You normally use NUnit to run Xamarin UITests. So an up to date nunit-console.exe should be able to run the UITests from your assembly on the command line.

    mono nunit-console path/to/your/assembly.dll

    Note that the version of NUnit that ships with Mono is quite old so you may want to use a more recent version which you can download from Note that Xamarin.UITest does not currently support NUnit 3 but NUnit 2.6.4 will be OK to use.

  • NuninzNuninz USMember ✭✭

    I've tried to use that command, this way:

    mono /usr/local/bin/nunit-console bin/Release/MyApp.UITest.dll

    It keeps throwing this error:

    Cannot open assembly '/usr/local/bin/nunit-console': File does not contain a valid CIL image.

    Which devices are the tests run on? can we pass that as a parameter?

  • NuninzNuninz USMember ✭✭

    Thank you. I got my UI tests running just fine. Although I noticed that you can only pass one device id. Is there any solution for that? I would like to trigger this once a day to run trough a couple of devices

  • mattwardmattward GBMember Xamurai

    Maybe you could use NUnit's test case source to pass in extra device ids? Or alternatively just have the test read some configuration information to get the device id (maybe environment variable?) - then have a script that runs nunit-console for each device id.

  • NuninzNuninz USMember ✭✭

    hm but I added the device id on the code:

    return ConfigureApp
    .iOS.DeviceIdentifier ("A0AD67D2-6BB8-4A84-88E9-9D13239308F5")... etc

    Is it possible to do that using this device identifier method? I'll investigate the environment variables on Jenkins and see how it works

  • mattwardmattward GBMember Xamurai

    Not tried it but since it is a string you should be able to make it configurable.

  • CJensenCJensen USMember ✭✭

    Hi nuninz,
    Have you solved the issue how to run the tests on several devices with Jenkins ?? .. I have exactly the same problem and is stuck here :(

  • NuninzNuninz USMember ✭✭
    edited June 2016

    Hi @CJensen . Yeah I did it this way:

    Run this command for each device

    IOS_ID="$ID" ${mono} ${nunit} ${WORKSPACE}/YourAppProject.UITest/bin/Debug/YourAppProject.UITest.dll

    $ID - this should be the device Id

    on your UI test code you should have something like this

    return ConfigureApp
    .iOS.DeviceIdentifier (Environment.GetEnvironmentVariable ("IOS_ID"))
    .EnableLocalScreenshots ()
    .AppBundle ("../../../YourApp.iOS/bin/iPhoneSimulator/Debug/")
    .StartApp ();

    I only did this for iOS so far but it should be the same way for Android.
    To get the device Id I'm running some bash script commands to get the Id based on device, iPad or iPhone, and version(9.1, 9.3, etc)

    You need to install the app first to run it. That nunit command will not install it for you. I'm writing a tutorial with all this stuff, it should be finished by the end of the week

  • CJensenCJensen USMember ✭✭

    Thanks a lot for sharing this and I will give it a go :smiley:

    I will look forward to your tutorial and if would appreciate, if you would be so kind to sent it to me on mail when done [email protected]

    Have a nice day

  • CJensenCJensen USMember ✭✭

    Hi Nuninz,

    I can confirm it works on Android as well .. :) ... You have saved my day :smiley:

  • NuninzNuninz USMember ✭✭

    cool! glad to hear that!

    the tutorial is on my blog, not finished yet!

Sign In or Register to comment.