Test-Driven Development on Android with the Android Testing Support Library (Google I/O ’17)

[Music] howdy everyone welcome to this morning’s session on scan-driven progress for the Android platform my identify is Jonathan garish and i am a part of the cellular ninjas we’re a small team within Google who’re enthusiastic about application trying out and am i able to get a rapid show of palms within the viewers what number of of you’re clearly writing exams as a part of your traditional software progress practice that is high-quality okay so in the event you’ve written tests for Android before you generally use a few of our tools we developed the Android testing aid library which includes the J unit for scan run own principles the espresso UI trying out framework and were also active contributors to robolectric the open-source Android unit testing framework so each person’s telling you to write down checks however why must you quite do it it’s real that exams take time to put in writing they may be including code to your codebase and maybe you have been in a concern before where your supervisor or purchaser has been telling you that they may be slowing you down however there is so many compelling motives to jot down checks tests offer you speedy feedback on failures so disasters which are noticed previous on in the development cycle a a long way simpler to repair than after they’ve long past are living secondly exams provide you with a safety web you’re free with a good suite of exams you are free to refactor smooth up and optimize your code risk-free within the knowledge that you’re now not going to interrupt existing conduct tests are rather the spine of sustainable program development you can be in a position to hold a stable pace during the lifetime of your task and you’re going to hinder the increase-bust cycles of crunch feature time and the aggregation of technical debt so in application trying out there exists the inspiration of the pyramid the checking out pyramid and that is made up of a number of layers and every layer brings with it its own alternate-offs that you are going to need to weigh at the lowest layer is the small assessments or the unit checks and these have to be very fast and extremely focused that’s why we encouraged you these variety of assessments is what is known as local unit tests and these are going to run in your nearby computing device machine and the exchange-off you are making with these kind of checks is infidelity on the grounds that you are not walking on a realistic environment and you’re typically substituting in a bunch of marks and fakes as we transfer up the pyramid we’re now into the geographical regions of integration testing and end-to-end testing and the important thing with these style of checks is to bring in constancy that’s why we propose that you just run these variety of tests on a real gadget or an emulator these are the style of checks which are going to tell you that your application absolutely works nonetheless they are much less focused so a failure in any such form of checks would take a little bit longer to monitor down that it would in a unit test and some of the colossal exchange-offs you are making is in scan execution pace because you’re assembling multiple add-ons all of them have got to be built and then package shipped to a device where the tests are run and the results elected back that is going to take time beyond regulation so there isn’t a single layer in this trying out pyramid that may suffice so what you must do is to blend in checks at each one-of-a-kind tier leveraging the strengths of 1 category to way off the exchange-offs in another there isn’t any real tough and speedy rule here however Google’s own internal checking out gurus endorse the 70-20-10 rule of thumb because the ratio between small medium and colossal assessments let’s take a appear at our workflow so and with test-pushed development the inspiration is that you simply start with the aid of writing your tests you then put into effect a code to make those checks pass and then when your exams a green you could post once more a speedy show of arms who in the market has experiment-pushed their code tried scan-driven progress up to now ok cool so we like experiment-pushed progress considering that it makes you to feel about the design of your application up front it gives you consideration to api’s and the constitution of your code with experiment-driven development you are also going to be writing much less code in view that you only write the code imperative to satisfy your checks this may increasingly allow you to unlock and typically as you constantly green you’ll be able to be competent to install a working application at a moment’s notice if we’re following the scan pyramid the workflow is going to look some thing like this first of all now we have a higher outer new release that’s involved with characteristic development and right here is began it can be pushed via a UI experiment and the mantra with scan-driven development is pink green refactor we begin off with a failing scan we enforce the code to make that test pass and then we refactor within the greater generation are a series of smaller iterations and these are worried with the unit checks right here that you are assembling the constructing the models required to make the feature pass and again you use the same mantra here crimson inexperienced refactor purple green refactor so let’s take a look an example utility so the feature going to enforce at present is the add notes go with the flow to a pattern observe taking application if we take a seem at our mock-u.S.We can see that we start on a notes list reveal filled with some current notes there’s a floating motion button down at the backside and the consumer will click this taking them on to the new add notes reveal here they may be able to enter a title and an outline for his or her observe before clicking save the node will likely be persevered after which in no way became again to the notes record monitor the place they may be able to see their newly introduced note together with any other notes that beforehand existed so coming back to our workflow for a second recall that we with a failing UI experiment so let’s take a seem at how this test would look like utilising espresso the UI testing framework step one is to click on on the add node button then we enter the title and description and click on save earlier than returning to the notes list monitor and right here we’ll confirm that the observe that we simply delivered certainly suggests up now keep in mind with experiment-driven development we’re now not put in force the code simply but and all we have to do is enforce adequate of the appliance to fulfill the specification of our exams so an empty endeavor and simply the resources that we need will fyz once now we have that we can run our scan and we’ll see it can fail now we have to implement this option so applications are constructed up of many small items these are small totally targeted specialized components that do one factor and they do it well collections these small items are then assembled collectively in order that they are collaborations will fulfill our feature let’s take a moment to summarize the key traits of make up a excellent unit test as well as the typical conditions you looking to you looking to experiment your failure conditions invalid inputs and boundary conditions which you can emerge as writing a number of unit assessments unit checks must constantly give you the identical influence whenever so hinder depending on things that might exchange for instance an external server or the current time of date on the grounds that that is going to convey flakiness into your unit exams unit exams should endeavor one exact facet of your code at a time you wanting to look that a failure in a unit test will lead you very quickly to an genuine computer virus for your code and while you write unit checks avoid making too many assumptions on the exact implementation of your code you need your unit has to scan conduct that way you avert rewriting your assessments when your implementations changing and one of the most primary features of unit test is they’ve bought to be speedy specifically on account that you’re writing so a lot of them and you’re in TDD workflow going for walks them rapidly and it could it could be horrible in the event that they were you had been discouraged from writing assessments or refactoring your code due to the fact that of the suffering in the execution time of those exams and in the end unit checks are an exceptional supply of documentation and the best way that’s continually evolving along with your code because it changes not like static records as a way to stagnate over time let’s write a unit experiment for our add notes pastime this pastime goes to absorb person enter and then we will persist it to nearby storage on the gadget k so we’re going to create the add be aware activity type and the select stand endeavor which is an android framework category it has a view which is going to be inflated with a layout and the person will enter their information right here and then we’ll persist that notice into Android shared preferences mechanism so it’s possible that as our software evolves so does our requirement and maybe our storage specifications evolve to persist the notes on to cloud storage and we must build some type of synchronization mechanism for nearby storage for the offline use case and in these cases we see possibilities for abstraction we would on this example see that we will extract a notes repository and nonetheless some of the key elements of test-pushed development is that we simplest by using writing the simplest case first after which we iterate so we’re going to withstand the temptation to do that early let’s take a appear at a pattern of what an idealized unit test would look like they may be frequently developed up into three stages so the primary stage is you’re environment the conditions for the experiment and this entails getting ready the environment establishing your dependencies with a required state and making ready an input data subsequent we will endeavor the code under scan earlier than eventually making assertions on the results or the state so I like to obviously separate every of these three phases of the assessments and carry the pertinent points of each experiment like entrance and center to make for particularly readable scan so up until now with the Android platform you’re writing your unit exams utilizing the mockable jar along side a marking library such as mojito and let’s take a look at an example of our experiment written with mojito k wow that’s quite a few code k so considering of we have so many interactions with the android framework and we’re going to have to provide stubbing conduct for all of them in order just to make just to meet the execution paths of our checks and additionally on account that Android makes use of various static approaches we’re pressured to introduce a second mocking library energy mark with a purpose to manage this special case for us and there are additionally some pretty bad code smells here let’s take a appear you see we’re forced to spy on the pastime underneath scan and we’re needing to do that to modify its habits and stubbing it out and providing some no ops so we’re relocating out of the geographical regions of blackbox testing right here and finally at the end we’re making assertions concerning the implementation important points and if these trade our assessments will have to change too so remembering the traits of a good unit test let’s take a second to attain this certain scan good it is rather targeted we’re just checking out the glad path of our add notes waft and it can be surely quick due to the fact that it’s running on the nearby JVM nonetheless we were making as an alternative numerous assumptions about the implementation in that scan and and with this if any of our implementation changes it’s probably we are going to have got to rewrite that experiment substantially and in the end all that extra boilerplate stubbing is quite distracting it’s distracting faraway from the important thing features of the test the stipulations the tests that you’re seeking to document well luckily there may be a instrument that helps handle a few of these problems so introducing Robo electric robolectric is an Android unit trying out instrument that’s open supply that we’re actively contributing to and to let you know extra about how one can write excellent assessments with robolectric i’m going to hand you over to christian williams the long-established author of robolectric thanks Jonathan it’s brilliant to see so many people who are into Android testing and TDD so yeah rub electric is that this a scrappy little open-source challenge that I began hacking on again in the early days of Android trying out for the reason that I was once simply super annoyed at how lengthy it took to to deploy and run checks on an emulator and it is kind of been a side undertaking of a bunch of one of a kind humans except final year once I had the privilege of becoming a member of my buddy Jonathan at Google the place he used to be already working on bettering robolectric for Google’s of interior experiment Suites and for the reason that then we’ve got been we now have been rather beefing up for electric and contributing again to the open source mission in these days robolectric isn’t an officially supported a part of the android plus trying out platform however we determined that after it is used adequately it may be a quite priceless a part of your testing strategy and i’ll show you just a little bit about how one can how you are able to do that too so let’s return to our observe student experiment and spot how we could process it with robolectric so considering rubb electrical runs as a neighborhood unit experiment it would still be going for walks to your notebook as an alternative than an emulator however robolectric presents type of a bit Android sandbox subsequent to your scan where the precise SDK code is strolling you can have entry to your routine your layouts and views and assets and you can generally just name most Android methods and they will kind of work like you’d assume there are ingredients of the android framework that depend on on native code or name it hardware or engage with outside system services so for that robolectric supplies a type of test double that we name shadows and people provide alternative boundaries of that code that’s proper for unit trying out so don’t forget that that experiment that we just saw if it had like 20 strains of code of like mock mounted code let’s see how that appears in robolectric so that is lots less we have gotten rid of the entire boilerplate the scan is ready half of the dimensions and far more concise we’re now not compelled to suppose about the implementation important points as we’re writing the test which is relatively fine Reb common sense goes to established your utility consistent with your manifest and here we’re asking it to installed our undertaking it runs it by means of the appropriate lifestyles cycle to get it into the proper state inflates views all that stuff it that we anticipate from on a device so that it will just have interaction with it as if you are on the device so we add some texts and fields click on on it and assert that it adds the notice to the repository now discover that we’re no longer truly going so far as the UI test that we saw that we wrote at the very starting we’re now not asserting that the brand new note seems on a view display that will be the job of an extra unit scan now I mentioned robolectric shadows they in reality supply elevated trying out api’s to a few Android classes that permit us allow us to question inner state and many times alternate your conduct on this illustration we’re asking the appliance if any of our hobbies requested that an intent be launched for the duration of the scan we would use that tornado that after saving a be aware to the repository we’ll go to the to the view notes pastime an identical trying out api’s exists for simulating Hardware responses or outside services things like that so at this point we have now a failing unit scan and now we get to we’re in a position for the effortless part writing the construction code within the spirit of TDD we’re only going to write down precisely as a lot as as is required to make the experiment pass no extra no speculative coding so we inflate a layout at acetic Handler and when the click occurs we like for you to notice an editor repository so now we are able to run the scan see a move if there’s some improvement we can make to the code we will return and refactor after which we repeat that is where you get the thoroughness and Rev electric is tremendous helpful for this because it gives you like high-quality rapid scan runs you can get right into a relaxed cycle so we wish to not discuss the happy direction right here we’re going to experiment all of the special circumstances we are able to there are codes probably to encounter so for example enter validation and outside stipulations like the network being down stuff like that Rob let that you would be able to additionally support with simulating gadget conditions that you can come upon for instance that you could specify qualifiers at the notes or that the experiment will have to run with right here we’re announcing like a particular display measurement and orientation which might change the design somewhat that you would be able to ask your lecturer to run your scan below a targeted SDK so we are going to say jelly bean here and it surely makes use of the SDK code from that variation and that you would be able to also tell Rob electrical I want to run this scan underneath each SDK that you aid or some some range of them that you are excited by and we aid jelly bean by way of oh right now so at Google we depend quite heavily on robolectric and we’re investing making it higher we have acquired dozens of apps including these which have 1000s of enormous quantities of unit exams walking internally so it’s well battle proven and now we have additionally not too long ago began running the Android CTS which is a dandy reliable Android scan suite once more strobe electric and we’re about 70 percentage passing correct now getting better with each free up so when you’ve used our electrical in the past and located that it’s come up short or if you’re caught in an historic variant undoubtedly endorse that you just you get up to the modern day due to the fact that it is been some distance we now have been engaged on lowering friction after which in integrating Rev electric with Android toolchain it really works now very good with with Android studio with Gradle and we’ve obtained help for Basile Google’s into Google’s possess open-source construct approach coming quickly so robolectric is not a one-measurement-fits-all trying out instrument it can be rapid but it surely’s not 100 percentage identical to Android in each method so you want to make use of it judiciously as we stated before avert writing unit exams that hyperlink multiple routine collectively that’s no longer a lot a unit experiment that’s a lot better for espresso when you’re dealing with more than one threads synchronization issues stuff like that you’re additionally quite often now not writing a unit scan so no longer excellent for electrical and in particular restrict using robolectric to scan reintegration with with android api s and things like Google Play offerings you quite ought to have higher stage assessments to offer you confidence that that is working so now that we have now got some passing unit checks i will have you ever over to my colleague Stephan to speak about our level testing thank you Christian so let’s go back to our developer workflow diagram and so at this factor we optimistically have a ton of unit tests they usually fully scan all our industry common sense but let’s switch gears and check out to look how we are able to without a doubt write some integration tests to peer how these models combine and the way they actually combine with Android and how they run in a real environment so on Android these tests are most often known as instrumentation tests and i am beautiful sure most of you’ve written an instrumentation experiment before and even though they seem super easy on the outside there may be really loads occurring below the hood for those who consider about it you have got to compile the code you need to method your resources you have to bring up a full method photo and then run your exams and there’s quite a few things that go on on more than a few phases of the Android stack so these checks offer you high fidelity but as John was citing they come at a cost which is they’re slower and regularly they are extra flaky than unit tests so let’s truely see how this works to your daily progress flow so shall we embrace you’re in Android studio you might have simply written your new espresso scan and you hit the Run button to run the experiment so the first thing that Android studio goes to do is it’s going to set up two apks for you the test apk and the app underneath scan so now the test APK comprises Android JUnit runner it contains the scan instances and your scan appear after which with the intention to run the scan Android studio calls below the hood adb shell am instrument after which Android Jade runner will use instrumentation to manage your app beneath experiment so what is instrumentation and i consider you guys could have you guys will have seen this it is a prime-degree tag on your occur and why is that instrumentation is really anything that you comprehend it’s used deeply within the android framework and it is used to manage the life cycle of your hobbies for finish so in the event you believe about it it can be a perfect interception factor that we are able to use to inject the experiment runner and that’s why Android drainage runner isn’t nothing more or less than an instrumentation so let’s go a bit bit deeper and see what happens when Android studio really runs your assessments so it runs adb shell am instrument that will turn out to be calling out to exercise manager endeavor manager will then call at one factor on create in your instrumentation so now that we all know that Android Jayne Runner is our instrumentation at this point it’ll name on create on the on the runner after which the runner is gonna do a few matters for you it is going to collect all your duties then it is going to run all these tests sequentially after which it’s reporting back the outcome one factor to notice right here is that Android JUnit runner and you will have observed this runs within the same approach than your application and extra importantly when you almost always use Android become a member of runner it runs the entire exams in a single single instrumentation invocation Android become a member of each and every runner is closely used within Google we run billions of exams each month using Android JUnit runner and even as doing so we saw some challenges that might that we face than if we needed to solve one factor that we see a lot is shared state and i’m not speaking in regards to the variety of like shared state that you simply manipulate and also you that you simply code for your app i am speakme concerning the shared state that builds up on reminiscence builds up on disk and makes you it has fail for no reason or you recognize unpredictable stipulations and this among other matters good at one factor result in crashes however within the prior mannequin that I simply confirmed you if if one in every of your assessments crashes your instrumentation it will take the entire instrument the entire app approach with it and all the subsequent assessments is not going to run anymore and that is without doubt a crisis for tremendous experiment suites in a similar fashion in case you suppose about debugging for those who run a couple of thousand assessments in a single invocation consider about what your Lochhead will look like and when you have to go for it for debugging so that’s why inside Google we have now taken an extra approach so inside of Google every experiment runs in each test process runs in its own instrumentation invocation so now you can do this today right you can you know make a couple of adb calls you can use a runner arc and hold your customized script however the trouble is it could now not quite integrate well along with your progress atmosphere so that is why at present i’m completely satisfied to announce the Android scan Orchestrator and the Android experiment Orchestrator is a technique that allows you to run assessments like we do in Google it is a service ivk that runs in a historical past and runs every experiment in a single instrumentation invocation and this undoubtedly has advantages correct there isn’t a shirt slate anymore and actually the Android test Orchestrator runs p.M.Clear before it runs its test more so crashes are actually absolutely isolated due to the fact we’ve single instrumentation invocations if a crash happens all of the subsequent tests will still run and similarly for debugging all of the debugging expertise that you simply gather and pull off the gadget is now scoped to a special experiment and this is fine and that is satisfactory and we benefit so much from it inside of Google so let’s see the way it surely works so on prime of putting in the scan apk and upon our scan what we do now’s we install a third apk on the gadget and it’s a carrier apk going for walks within the historical past containing the orchestrator and then alternatively of walking a couple of adb commands we run a single ATB command but we don’t instrument the app below test we instrument the orchestrator immediately after which the orchestrator is going to do all its work on the gadget so it’ll use android trade runner to collect your exams however then it will run each of these tests in its possess invocation and it can be potent and i am pretty certain you will you are going to like this loads and it’ll be to be had in the subsequent Android testing support library free up and more importantly we will be able to have integration with Android studio it’s going to be on hand in Gradle and we will also have integration with firebase experiment lab coming later this 12 months so now that we all know methods to run our exams let’s truly appear at how we can write these integration checks and frequently if you write a UI experiment on Android you’re making use of the espresso checking out framework and as one can find espresso has this like best and simple API and it simply works beautiful simple what it does is you give us a view matcher and we find a view in the hierarchy that matches that matcher and then we both perform a view motion or check a view assertion and considering the fact that this API is so easy it is the excellent device to for fast TDD prototyping of UI exams however in an effort to provide you any such simple API there’s a variety of things that ought to go on under the hood so let’s clearly appear how espresso let’s appear at how spresso works so whilst you call on view and give us your matcher the first thing that we’ll do is we’re going to create a view interplay for you and then the subsequent factor is we make certain that your app is in an idle insane state earlier than we’re equipped to interact with it and that is you could believe of it that is on the core of espresso and espresso is well-known for it like synchronization guarantees and the way we do it’s we loop the message queue until there are not any messages for an inexpensive period of time we seem at all of your Eiling assets and ensure they’re idle and we additionally look at async tasks to be certain there is not any background work walking and provided that we know that your app is in a sane and steady State and we’re competent to engage we will move on and then we’ll traverse the view hierarchy and in finding the view that fits your matcher and once we’ve the view we then going to perform a view motion or a view certian and this is pleasant so now let’s circle back to the scan that we confirmed you in the commencing and have a more in-depth look now that we know how its pressure works so within the first line as you can also recall we attempt to click on the add node button and here we simply going to use a width identification subject which is a straightforward matter that is matching a view within the view hierarchy consistent with its identity and subsequent factor we need to do is we wish to click on on the view and we use a click view motion for this so now the place it will get exciting is the subsequent line when you consider that on this line we need to variety the title and description and we need to use a style textual content action for that but right here the entire espresso synchronisation guarantees will kick in and provided that we all know that we’re in a position to engage along with your implication we’re going to invoke the variety test motion and that is pleasant considering the fact that it frees you from adding you already know further boilerplate code and additional slipping code to your scan so similarly we will keep the node and then we’re going to verify that it’s displayed on reveal and this is nice now we know how espresso works and we know how it’s a nice instrument to do scan-pushed development and now i will quit to Nick to speak just a little bit extra on how you can enhance your UI test and the best way to beef up your colossal and medium checking out procedure thank you so enjoyable so one good attribute of a UI test is a experiment that never sleeps so let’s return to our instance to illustrate this point a bit bit further so in our examples you take into account we have a observe that we keep into reminiscence which is beautiful fast and beautiful dependable nevertheless reliably reality as your app grows you probably need to prolong this performance and save your word to the cloud or Google drive for instance so when going for walks our huge finish-to-end scan we want to use an actual environment where we hit the real server and depending for your community connection this may take a very long time so you generally need to do is within the heritage now the hindrance is now could be that espresso synchronization just isn’t mindful of any of your long-jogging duties so that is someplace that some where developers will most commonly do whatever as ugly as placing a thread sleep of their code however what this presser shouldn’t be really required because that you may write an idling resource where an idling useful resource is a simple interface for you as a developer to put in force to educate espresso synchronization of any of your custom long strolling tasks of your app so with this ionic resource we made our huge finish-to-end experiment extra trustworthy so let’s examine how we are able to add some more medium-sized stats to your scan suite so for a medium-sized scan we wish to maintain them small and all in favour of a single UI factor whereas single UI aspect may be like a unique view fragment or an undertaking so let’s go back to our instance to peer how we are able to isolate our significant finish-to-finish scan to more remoted add-ons so here on this instance again you could have observed that there are two movements the record exercise on the left and the add node activity on the correct so unless now we wrote a colossal end-to-finish scan that offers us a number of self assurance considering that it touches upon quite a few your code in your app which is fine for massive intent test but it surely’s now not so fine for an iterative scan-pushed progress cycle so so let’s see how we will isolate these and have remoted checks for every undertaking in isolation to isolate the left-hand side the record exercise we can use espresso extreme we’re espresso excessive is a straightforward API that allows you to intercept any of you are going a anxious confirm their content and provide back a mock pastime outcomes great so let’s have a look at how that API genuinely appears like so as you will discover it can be very easy you could have an intent matcher a good way to healthy your going intent and which you can provide a version of your endeavor influence again to the caller k so let’s use this API to put in writing our first remoted experiment so on this test you’ll discover on the primary line we do just that we intercept our intent and we furnish a stub variant of our exercise outcomes now on the 2nd line once we participate in click rather of opening a new exercise espresso will intercept this intent and furnish a subjective outcome which we can then use on the last line to affirm that our UI was up-to-date consequently now now we have an isolated test ok so let’s go back to our instance and see how we will isolate the 2d section correct so when you write when by and large write assessments you come to be competent where you could have some outside dependencies in play that may examine which can be external of your control so in our instance right as I showed earlier than we’ve i know that we store and it hits the actual server now even though we’ve an auditing resource now that makes it extra safe your exams can still fail since your server may crash for some intent so your scan will fail so wouldn’t be higher if we totally isolate ourselves from these stipulations and run our assessments in a airtight environment this won’t simplest make your test run so much turbo however it will also do away with any flakiness and past this exact illustration you additional wish to isolate yourself from any external dependencies so for illustration you don’t want to scan any Android procedure UI or another UI components that you do not own considering the fact that they traditionally already established and they can additionally alternate with out your knowing so your assessments will truely fail so let’s examine how our 2nd remoted scan will look like in code so here we see the foremost factor here is that we now not use the true server and as a substitute you know we mounted a airtight repository now there is many specific methods of you to do this and this is only one means so then you should utilize this harmonic repository to be able to verify that your notice is sincerely saved with out ever leaving the context of your app or hitting the network so at this point in case you consider about it you’ve got two smaller exams that run rather more they are far more safe and run much rapid but whilst you hold the equal quantity of test insurance plan as your significant finish-to-end scan and for this reason we need to have extra of those smaller remoted checks in comparison with the massive end-to-finish tests we showed before okay so at this factor we iterated through our developer cycle a few times and we must see all of our assessments start turning green and we will have to be constructive to free up our characteristic nevertheless earlier than we conclude let’s leap into the long run for a 2d as your app grows and your group grows you continue including more and more elements to your app and you can also find your self ready the place you might have UI running in more than one procedures which is strictly what occurred at Google so if you happen to go to our notes illustration this may occasionally appear anything like this you could have a first activity that runs on your important procedure on the left-hand aspect and now the 2d activity will run in us in a exclusive system and on this case we’re going to name it add notes so how will we experiment that well earlier than Android oh it used to be impossible to test however with Android oh there is a new instrumentation attribute that you should utilize to be able to define which method you wish to have to instrument while instrumenting and strolling exams against each system in isolation is a pleasant notion and also you must do it you may also to find yourself capable where you want to pass procedure boundaries within one experiment so you possibly can as a rule need to write an espresso scan like looks like this at the same time this was once not only possible in a framework stage earlier than Android oh this used to be also not possible on this primary stage seeing that in this targeted instance specific is just not even mindful of your secondary procedure nor can it preserve any of the synchronization ensures we all know and love so today i am comfortable to announce multi-method espresso support without altering any of your test code or your app code this will likely enable you to seamlessly engage with UI pass procedure even as retaining everybody presto synchronization guarantees and it’ll be equipped to be had in the next variant of Android scan support library release so let’s have a rapid overview of how it definitely works so quite often as you realize in our example we start in one procedure where we have an illustration of an usual runner and espresso on this case now when you don’t forget from our illustration when you click the add node button there can be a brand new exercise and now we have now a new system so the drawback now’s that we now have two processes with two exceptional circumstances of an normal runner and espresso and so they’re no longer aware of each and every other so the first thing that we need to do is we would like to set up communication between the two and regenerate runner and now that we have this verbal exchange we will use it to set up the verbal exchange video to espresso occasions and the way in which we do that’s by way of having an potential in hydrogen as runner to register any testing frameworks like espresso with an long-established runner and then the runner will then facilitate all of the handshaking required in order to set up verbal exchange between the two espresso situations now that the 2 suggestion instances can speak to each other it might then use it so as to enable go approach trying out and keeping the entire synchronization guarantees that we had earlier than okay so with that we’re achieving the top of our developer workflow and we showed you the entire instruments that you can use across every step of the best way in an effort to make TDD happen and on Android and with that said although you don’t comply with this drift exactly optimistically you know how to use every single device and learn how to write just right tests as a way to bring your app excellent to the following degree so in case you like to write assessments and you need to write an on scan like we do at Google here are some resources to get you began however I wish to thanks and that i feel now we have some time for questions and if no longer we now we have office hours at three:30 today so expectantly you see that thank you [Applause] [Music]

As found on YouTube zxczxcz

Add Comment