Setting up Visual Studio for Xamarin Test Cloud


test-cloud

1.Problem Statement

After Xamarin was acquired by Microsoft, it became a natural expectations from the Xamarin developers and testers to have the scripting support available from inside the visual studio environment. This article will explain you about how to setup visual studio with required SDK and tools and how to write your first script and upload it on test cloud.

2.Before we start!

 

3.Getting ready

Download Visual studio community version and then follow the following steps.

1

  • Double click the downloaded file and Click on the “Run” button.2

 

  • After Clicking on the run button, a pop up will prompt on the screen. Select the “Custom” option and click on the “Next” button.    3        
  • Once you click on the “Custom” button you will land to this page.4

            

           

4.Complete visual studio Installation Instructions:

To complete the installation process we would require certain tools as listed below:

  • Common Tools for Visual C++ 2015.
  • Microsoft Sql Server Data Tools
  • Microsoft Web Developer Tools.
  • Windows 10 SDK(10.0.10586)
  • Visual C++ Mobile Development
  • Android Native Development Kit(R11C,64 Bits)[3rd Party]
  • Apache Ant(1.9.3)[3rd Party]

 

In order to complete the installation of visual studio, please follow the steps mentioned below:

5.Steps:

  1. To install, expand Programming Languages and select “Visual C++”. Under Visual C++ select “Common Tools for Visual C++ 2015” and click on the “Next” button.option1
  2. To install  “Microsoft SQL Server Data Tools” & “Microsoft Web Developer Tools”  Expand “Windows and Web Development” tree and select “Microsoft SQL Server Data Tools” & “Microsoft Web Developer Tools” and Click on “Next”.option2
  3. To install “Windows 10 SDK (10.0.10586)” Expand the tree of “Universal Windows App Development Tools” and select “Windows 10 SDK(10.0.10586)” and Click on “Next”.option3
  4. To install “Visual C++ Mobile Development”, expand the tree for “Cross Platform Mobile Development” and select “Visual C++ Mobile Development” and then it will automatically select “Android Native Development Kit (R11C,64 bits) 3rd Party”, “Apache Ant(1.9.3)3rdParty” to complete the installation of these tools click on “Next”.option4option4-1
  5. Click on “Install” to complete the Process.  option5  visual-studio-modify-runing

 

6.Create a Test Project

1.Open Visual studio.

2.Click on “File” and add a new “Project”.3

3.Select “Test” from the left panel and from the right pane select “UI Test App(Xamarin.UITEST|Android)”.4

 

4.Enter the name of the project .

5.In the SETUP section enter the path of the apk file.

 

7.Create Test Script (for example, script for Login)

 
using System;

using System.IO;

using System.Linq;

using NUnit.Framework;

using Xamarin.UITest;

using Xamarin.UITest.Queries;

using Xamarin.UITest.Android;

 

namespace AppLaunch

{

    [TestFixture]

    public class Tests

    {

        AndroidApp app;

        [SetUp]

        public void BeforeEachTest()

        {

            // TODO: If the Android app being tested is included in the solution then open

            // the Unit Tests window, right click Test Apps, select Add App Project

            // and select the app projects that should be tested.

            app = ConfigureApp.Androi.ApkFile(@"PASTE YOUR APK FILE PATH                    HERE").StartApp();

                   //THis will launch the application.

        }

        [Test]

        public void AppLaunches()

        {

            // app.Repl(); //It allows a user to interact with the object hierarchy.

            app.EnterText(x => x.Marked("input_userName"), ""); //It will enter the username in the username field.

            app.EnterText(x => x.Marked("input_password"), "Rajit"); //it will enter the password in the password field.

            app.Tap(x => x.Marked("loginBtn")); //Tap on the login field.

   }

    }

}

 

8.Build Test Project in the Release Mode

a.Select the mode as “Release”.5

 

b.Click on Build from the main toolbar and select “Build Solution”.6

 

9.Upload the Script on Test Cloud

 

a.Sign Up at : https://testcloud.xamarin.com/

b.Click on “New Test Run” on the header barxac-1

 

c.Select the platform(Android/IOS) and click on “Next”.xac-2

 

d.Select the specification (OS version, Manufacturer, Memory, Device family, Processor) from the left panel, select the device from the centre and Click on the Select x device button in the bottom.xac-3

 

e.You can run your script in series if you want to maintain otherwise keep the master series selected and click on next.xac-4

 

e.On this final step you can select following things:

  • Select the language of the script (C# or Ruby)
  • Platform of your system where the script is written
  • And copy the generated command

packages\Xamarin.UITest.[version]\tools\test-cloud.exe submit yourAppFile.apk ff2d3a610f6b0e01460446fbf22a48e1 –devices bbb58a62 –series “master” –locale “en_US” –user user.name@walkingtree.tech –assembly-dir pathToTestDllFolder

 

Note: At the end paste the folder path where the Dll files are placed.

 

The complete command should look like this:

test-cloud.exe submit com.walkingtree.Sales360.Droid-Signed.apk 8889f97cfeeb047204a5fb0df65f321d –devices bbb58a62 –series “master” –locale “en_US” –app-name “Sales 360” –user user.name@walkingtree.in –assembly-dir “D:\Src\Sales360\Sales360\Sales360.Droid\AppLaunch\AppLaunch\bin\Release”

 

  • Click on Done.xac-5

 

10.Steps to follow in your local system to upload script:

a.Open CMD in your local machine.

xac-6

 b.Type Cd and press “Enter”.

c.Type “d:” and press “Enter”(Reach out the drive where your script is placed in your system).

d.Reach the testcloud.exe file inside packages folder.

For me it was:

D:\Src\Sales360\Sales360\Sales360.Droid\AppLaunch\packages\Xamarin.UITest.1.0.0\tools

Copy that path and type cd D:\Src\Sales360\Sales360\Sales360.Droid\AppLaunch\packages\Xamarin.UITest.1.0.0\tools and press “Enter”

e.Now enter the command we copied from test cloud and press “Enter”:

test-cloud.exe submit com.walkingtree.Sales360.Droid-Signed.apk 8889f97cfeeb047204a5fb0df65f321d –devices bbb58a62 –series “master” –locale “en_US” –app-name “Sales 360” –user vaishali.tailor@walkingtree.in –assembly-dir “D:\Src\Sales360\Sales360\Sales360.Droid\AppLaunch\AppLaunch\bin\Release”

Once it is done the command prompt will look like this:

11.Summary

In this article, I explained how the visual studio can be configured to setup the Xamarin Test Cloud Environment on a given machine. Often the test automation falls under QA team and they do face challenges with the initial setup of the Xamarin Test Cloud environment. I hope this blog will help you in getting started with Xamarin Test Cloud without much fuss.

At WalkingTree we encourage our customers to have the test automation in place. Xamarin Test Cloud has been a big savior for us and we do recommend our customers to utilize this.

References:

 

Tagged with: ,
Posted in Xamarin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out https://walkingtree.tech/index.php/blog for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Recent Publication
%d bloggers like this: