 Welcome to Visual Studio Toolbox. I'm your host, Donovan Brown. Today, we're going to talk about using Expresso test inside of Xamarin Test Cloud. My guest today is Adam. Adam, welcome to the show, and tell me what you do here at Microsoft. Well, thanks for having me, Donovan. Sure. I am a test cloud engineer on Xamarin here at Microsoft. Okay, great. So, I pretty much help organizations get ramped up with automation testing. Okay, great. So, I'm familiar with Xamarin Test Cloud, but it sounds like what we've done is we've added some other types of tests that we support there. Yeah, exactly. So, for a few years, we've only supported two frameworks, CalBash and Xamarin UI test. Okay. And just recently, we rolled out support for Appium and Espresso. So, for today, I'm going to be showing how you can take an existing Espresso test and make it work within Xamarin Test Cloud. That sounds awesome. So, I can actually leverage the investment that I've already made in Expresso and now leverage that inside of Xamarin Test Cloud. Yeah, exactly. So, that's been one of the biggest cruxes about it, because if you're only limited to a few frameworks, it kind of pigeon-holds our testing solution. So, when we open this up to other frameworks that you can take and upload, it makes it a lot easier for customers to adopt Xamarin Test Cloud. Okay. So, before we get too far, we're assuming people know what Xamarin Test Cloud is. So, why don't we just take a second right now and tell those who might not know what Xamarin Test Cloud is, what it actually is. Sure. So, Xamarin Test Cloud is a mobile device lab containing thousands of devices. So, where it's best used at is when you want to deploy maybe nightly builds of your testing solution or weekly builds for regression testing, and you don't have every single device that your users have to launch your mobile application. Got it. So, you can deploy your test with your APK or IPA to Test Cloud and see how it looks and see all the results. Right. When you say a device lab, these are thousands of physical devices. Thousands of physical devices. Right. These are not emulators or simulators. This is your ability to take your application, actually install it on an iPhone 7, which you might not own yourself, and be able to execute test against that. Right. Because what a lot of companies do is procure just a ton of devices. Right. And those devices become obsolete. Absolutely. With Test Cloud, you don't have to worry about that. We have a procurement team that's going to take all the devices that are coming out on the market, and they're going to be there for you to test. Right. So, I don't have to worry about having this suitcase full of devices. Not to mention, even if I had all the devices, I would then manually have to go test on all those devices, and what we're doing is allowing you to automate that. Because for those who know who I am, I'm a huge DevOps guy, and I'm all about automating everything we can and using team services to do that. So, the Xamarin Test Cloud test can actually be executed as part of my automated build, correct? Absolutely. Okay. So, that was actually one of the big reasons why I decided to join the team. Okay. Like, I saw a huge need for automation testing because prior to this, you'd have like a manual tester, a developer with a mobile device connected to his machine or maybe a simulator, and they would have to go through hundreds of user scenarios. This isn't really repurposeable in any way. So, with automation, with VSTS, with Test Cloud, you can automate on almost every device out there and save a ton of time. Awesome. So, show me how it works. Yeah. Sure thing. So, here I have an instance of VSTS and I've created a couple of build agents that we can look through. So, the first two I want to focus on is XTC Weekly and XTC Nightly. What XTC stands for is actually Xamarin Test Cloud. Perfect. Okay. Great. So, we're going to be deploying this based on different timing within our DevOps development cycle. Okay. So, these are builds that are going to run either every night or you're going to run every week, and based on when I run them, I might change the number of tests that I'm going to run. Right. Exactly. So, I mean, it's rare when you see a development cycle of a week long. Typically, it's like two weeks or like a month, but if you want to test every single scenario that you have in your arsenal along with every single device that we have in our Cloud, you can set that up. So, that's what this first test is going through. The second test is if you have smoke tests. Okay. So, if you see devices that you're not, that are coming up red, you have Arizona, you can target those specific devices. Got you. If you have a certain tests that aren't passing as well, you can target those tests. So, you can get your results back a lot quicker. Got you. You don't have to waste time running tests. You know we're going to pass. You can focus on the tests that are causing you issues. Exactly. All right. Perfect. So, let's take a look at this. Sure. If I click into this build, what I'm going to do is just quickly queue it so we can see what's going on. Okay. So, queuing a build is basically telling the system, please go run one of these real quick. Right. Exactly. So, we have to wait for our hosted agent to spin up, which shouldn't take too long. I actually have just a few tests as well that we're going to deploy and the mobile application that I have is pretty small too. Okay. Great. So, the hosted agent, for those who don't know, our agents that we have in the Cloud for you automatically just waiting to do your build. So, you don't have to install these. They're literally sitting in Azure just waiting for you to do your builds for you. Now, you can also stand up what we call private agents, which is where you actually stand up the agent on your own and that way you don't have to wait for us to go find an agent for you. We just jump on your agent and go ahead and run some builds. Do you have an example of a previous build that's already runs or we can see like what happens at the end of it? I do. So, let me go ahead and just navigate to that. So, here's an example of one that was able to deploy in every single step successfully passed. Okay. So, what's happening here? Once it initializes the agent, it's going to grab our source code and again, this source code is of an Android native application written in Android Studio. Okay. So, I actually have this. If I switch over, this application that we'll be testing is very simple. It's just a demo app and you can see it running on the simulator on the right-hand side. Okay. So, every one of these cards is a note. So, you can take notes and it's more or less like Evernote but very slimmed down version of it. Perfect. But if I wanted to create a new note, I would just have to click on this plus sign, say, Espresso demo and right. Awesome. So, once we have our note, we can save it to our list and that's basically all a user can do. Okay. Right. So, what this application, or what this test is designed to do is to go through that same user flow. Okay. Now, with Espresso tests, you can take existing Espresso tests that you already have built out, tweak it a little bit to run in test cloud and that's actually what I did with this. So, Android developers out there may be familiar with this Gradle, the build.gradle file. All you have to do to incorporate it, at least add the appropriate dependency is this line of code. Okay. So, whenever a test is being called and this test task is being called, it will automatically build out the right APK file that you need. Then, once you have that enabled, you can go into your test itself, add these two lines and it's basically importing namespaces for you. Yeah, exactly. Got you. So, this is pretty cool because I realize that you're on a Mac and this is a point where I like to tell people that when we're talking about Visual Studio Team Services, it's not just for your PC, it's not just for your .NET developers anymore. This is for any language targeting any platform because we're talking about a native Android app written in Java on a Mac being built with Visual Studio Team Services and run in Xamarin Test Cloud. Yeah, exactly. I think that's the beauty about DevOps because you can take a lot of different tools from a lot of different areas and put them all together. Yeah, and build that pipeline that you need. Exactly. Exactly. Okay, cool. So, we make a few tweaks to our test by adding a dependency, adding a namespace, and now when I run this build through Team Services CI system, I'm now going to get the APK I need to then give to Xamarin Test Cloud so that it can execute my test for me. That's correct. All right. Perfect. Then, it's going to go through that exact same flow that you did and verify that that note was actually added, and then I can get those results back in my build. Definitely. All right. Great. So, just an additional note here. Sure. One other thing that you will have to add is this report helper. Okay. So, what's wonderful about this is that it makes the code really easy to read. So, we can see that we're on the main screen, we add a new note, and every action that we're performing, it's going to stop and take a screenshot of this inside of Test Cloud. So, this is the indicator in Test Cloud or tells Test Cloud where to take a screenshot. Okay. So, you show me how that looks in Test Cloud. How can we see that? Right. So, if I just hop back over and we can go into one of our tests. In fact, you can see this validating means that our build that I executed got to that step and it's already launched. Okay. But if we go into a previously launched test and view the results. So, once I enter in a test that it goes to our dashboard, which gives us a very high-level look at some reporting tools, or reporting analytics. I see. So, this is the name of the test you ran and these are those markers that you put in there with that line of code you're telling us about. Okay. So, this is more true to test-driven development. Okay. Right. So, every single step that a user would take is indicated here and then that corresponds directly with a screenshot. So, right now it's just getting launched up. You can see in some of the screenshots that the app is actually loading. Yeah. But once I continue, you're able to see us entering a text or the title and the text and then saving it. Awesome. Right. What's really nice about this since these are real devices, you can even zoom directly into one of them and get much more detailed analytics of what's going on. So much so that you can see memory usage, CPU usage. You can download the device log. Incredible. And all of this is incredibly helpful for developers when they want to troubleshoot an issue. Yeah. And allow me to be able to diagnose what's going on without me having to go and run it myself or even try to go find one of these particular devices to go run the test on. Exactly. So, incredible stuff. So, now what we're doing is we're allowing you to use Xamarin Test Cloud with give me the four test frameworks again. So, the four supported test frameworks is Appium, Espresso, those two are new. Okay. And Calabash and UI test. Perfect. So, I want to thank you so much for coming on the show and showing us how to use Espresso with Xamarin Test Cloud. Thank you so much for watching guys and we'll see you next time. Thanks.