Monday, May 16, 2016

Complete Mobile Dev Ops with Visual Studio Team Services and Xamarin Test Cloud

Wow it has been over six months. Sorry! As you can imagine, things have been busy in 2016. There has been an acquisition, Xamarin tools made available for free in Visual Studio, and then Xamarin Evolve. Now that things have settled down, and integration into Microsoft underway, I wanted to take this as an opportunity to get back to making semi-regular posts once more.

When I joined Xamarin in December of 2013, it was still largely a one product company. Xamarin enabled you to develop apps for Android, iOS, or Mac using C#. (OK, technically three products but to a degree you can look at them as different facets of the same tool).

Since that point Xamarin has grown to help assist in the full mobile development lifecycle. This included the launch of Xamarin University for training, Xamarin Test Cloud for better testing and Xamarin Inisghts for crash reporting, messaging and analytics. With Xamarin now under the Microsoft umbrella, a few new tools are available to even further complete that picture. The focus of this entry will be on how to leverage Visual Studio Team Services with Xamarin, both development and Xamarin Test Cloud, to create a full Dev-Test-Publish lifecycle.

Getting setup with Visual Studio Team Services
I won't spend a whole lot of time on this. The basic checklist can be found below.

1. Create your VSTS account
2. Create your Project
3. Connect to Visual Studio
4. Set up your repo and code

The main setup guide hub can be found here: https://www.visualstudio.com/get-started/setup/set-up-vs

For my scenario, I ended up using git as my repository, which would also be my recommendation if you don't have a previous requirement or preference.

Integrating Xamarin Test Cloud
Now that you have your code integrated with VSTS, and uploaded, the next step is to create a build process that confirms your build and also calls to Xamarin Test Cloud for regression testing. That way, any time a developer on your team submits their code, you can confirm everything is still working. Please note, this will require having created a UITest project and at least one step to run. If you have not ever done this, you can find more details here:
https://developer.xamarin.com/guides/testcloud/uitest/intro-to-uitest/

Now, the final piece of this puzzle is to integrate this as part of your VSTS build chain. Microsoft actually made this process quite straight forward, once I had my head wrapped around the tooling. A full general doc, found after I got it sorted myself, can be found here:

https://msdn.microsoft.com/library/vs/alm/build/apps/xamarin

This is what I wanted to break down and guide in more detail. First, select the Build tab in the VSTS portal and hit the green "+" button:

This will create a new dialog window. This is where you will select your build type. For our example we will use Xamarin.Android template. If you need iOS, you would match this process with iOS.

So many options
From here you can use the default settings, you want to select your Repository in question so that it uses this code for the build. If you notice in my example, I have "Continuous integration" selected. I recommend this if possible as it will allow you to run these tests whenever code is submitted to the branch.

Once you hit create, you are then resented with a dialog to configure the specific build settings. There are a three steps that require input:





But it can be boiled down to
1. Your license login (user name and password) information to activate\deactivate your Xamarin credentials
2. Xamarin Test Cloud API Key, Device ID, Test Cloud email

As a pro-tip for the password, the password field defaults to a plain text entry. What I would recommend is select the variables tab, and add your password as a variable, with the lock icon selected to flag it as "Secret".
MyPassword is the variable I have created.
Then in the password field you just use that variable with the syntax $(_VARNAME_). Much more secure than plain text usage.

For the "Test" step, you need to provide a few pieces of information.

First is your Test Cloud API Key, which is found under Teams and Organizations on your Test Cloud account. You can find details on obtaining that here: https://developer.xamarin.com/guides/testcloud/organizations-and-teams/#Obtaining_the_Team_API_Key
 
If you are not currently using Xamarin Test Cloud, fear not! We have a free trial that you can try out. More details can be found here: https://testcloud.xamarin.com/register

Again, you need to provide an email, this time the email of registered/added to the Test Cloud account. This may or may not differ from your Xamarin license details.

The devices ID you can acquire when you create an upload on Xamarin Test Cloud. The final step will give you a command line prompt that can be used for Windows or OSX and included is a --devices (#########) flag. This id is the final piece of information as it tells Test Cloud what devices the test needs to be run on, and can be reused from run to run. I would recommend recording these ID's as currently there is not another way to retrieve them to my knowledge.

Once you have entered all this information you have everything you need. At this point I would recommend selecting "Queue build" to do a test run with what you have uploaded, troubleshoot issues as needed. Ideally you should see this:
Green is good!
That's it! You have made your first step into a larger world of end to end mobile development and more efficient DevOps! Now, any time you submit code from git, this build step will be executed and you are on your way to writing higher quality code. Use this to make sure you are keeping your app at a high quality, and catch bugs and regressions before your users do!

3 comments:



  1. Thank you for putting an effort to published this article. You've done a great job! Good bless!

    Mobile Application Development and Testing Training

    ReplyDelete
  2. Hello James,

    Its an informative Article on Complete Mobile Dev Ops

    I learned a lot of from this article is with step by step process of Mobile App Development
    Thanks for Detail Article

    ReplyDelete
  3. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    Mobile App Development Company

    ReplyDelete