Automation Unit Tests VSTS (visualstudio.com)

RobertAlMalak.7208RobertAlMalak.7208 USMember
edited April 2017 in General

Hi everyone,

I been working really hard lately to get VSTS to play nice with Unit Test projects for Android and iOS. This is what I have/want:

  • Build on VSTS
  • Run unit test project (Using existing Xamarin Native project with Shared project, so dont have a PCL to make a normal NUnit project, have to use the Unit Test App (that runs the emulator/simulator to run tests))
  • Deploy to hockey app.

Couple of things iOS is now fully working for me. I found a great tool that Rolf created (Touch.Server) which I followed a certain guide to make it play nice with VSTS and output the results to a directory and then read it from there. The "Touch.Server" will automatically Run the device on my Mac agent and then put the test results into a directory (yay! awesome).

So now I want to do the same with Android and get the unit tests automated so I can run my unit tests as well. (Currently I have the VSTS build and hockeyapp deployment all done). Meaning I would need some kinda way to run the Android emulator through VSTS (I am thinking adb tool together with "Command Line Task") -> output a Results XML by doing an adb pull and then grab those results with the publish unit tests Task.

So I Instrumented my Android and it works locally (yay!). So I can run tests through command line with an adb instrument command. So next up I think I am going to:

  • Build Android
  • adb apk to emulator
  • adb instrumentation (I have a custom NUnitLite because I needed to add AppCompatActivity I saw where it outputs the directory so I can modify that to a known directory where I can pull from)
  • adb pull test results
  • publish test results

However this seems really extensive and might give me headaches to setup on my Mac agent (that I have full root access to). Is there a better way kinda like Touch.Server. Did Xamarin ever think of creating a new step to support Android and iOS unit test projects where we specify emulator and the unit test project and does this automagically ?

Let me know guys if anyone comes up with a great idea to help me out here with the Android unit tests project CI build/run.

Notes:

  • NUnitLite doesnt support AppCompatActivity I had to download the source and replace Activity with AppCompatActivity in TestSuiteActivity.cs
  • Touch.Server is not bundled anywhere nor is it anywhere documented by Xamarin, can you guys just add it to Unit tests project library in the future, its a life saver tool.

@RolfBjarneKvinge

Sign In or Register to comment.