Annyce Davis

ones and zeros

  • Home
  • Public Speaking
  • About Me
  • Courses
  • Life

Testing Hybrid Jetpack Compose Apps

September 6, 2021 by Annyce Davis 1 Comment

We’re developing a hybrid Jetpack Compose application. It’s comprised of one Activity and several Fragments. Each fragment includes a ComposeView directly as the entire screen is built with Compose. But how do we write tests for this?

Continue Reading

Bash Scripting for Flutter Tests and Code Coverage Reports

March 19, 2019 by Annyce Davis Leave a Comment

Do you have a development task that is mostly a series of commands? Do you have to perform that task on a regular basis? If so, a script might be just what you need. Over the years I’ve wanted to learn bash scripting several times. Yet there’s always something else that takes priority and my desire to script takes a back seat. Not any more!

I finally decided to start learning how to write bash scripts and I want to share it with you in case you’d like to do the same. At the bottom of this post, I’ve listed several resources that I’m using to help me on this journey. If you’re an Android developer, you can use Gradle to handle many automated tasks. If you want to learn about Gradle on Android or how to create a Gradle plugin, check out my course here.

On to the script. It does the following:

  • Runs the unit and widget tests for a Flutter application
  • Generates a code coverage report
  • Removes the unwanted files from the coverage output
  • Converts the coverage data to HTML
  • Opens the HTML page in your browser

I’m going to break down what each section of the script does so that you can start having fun creating your own scripts! (This post assumes you are already familiar with programming and related concepts.)

Continue Reading

Talk: Screen Robots UI Testing with Espresso

May 9, 2016 by Annyce Davis Leave a Comment

Often when writing tests with Espresso you find a lot of onView, withId, perform calls scattered throughout your test methods. This takes away from the simplicity of the test, tends to be verbose and also litters resource ids everywhere. There’s got to be a better way, right? Yes, there is…Screen Robots. In this presentation you will learn how to take advantage of the Screen Robot abstraction technique.

It covers: UI Testing, Basic Espresso, and Screen Robots

Materials

  • Slides
  • Sample Code
  • Blog Post
 
If you would like to learn more about creating high quality Android applications, I encourage you to check out my video course and bite-sized video content on Caster.io.

Testing Tricks #5 – Using Screen Robots with Espresso

April 18, 2016 by Annyce Davis Leave a Comment

In this presentation by a developer at Square: “Software Quality/Automation Testing”, he discussed how they take advantage of Robots to make it easier to update tests whenever UI elements change, as well as a few additional benefits. This is a very useful abstraction technique for when you’re writing large numbers of tests in Espresso. So let’s look at an example of using a Screen Robot to test a simple login flow.

Before Using a Screen Robot

So the above code is how you would typically make use of Espresso, where you have multiple calls to onView() and reference the resource ids directly in each test. Two main drawbacks of this approach is that 1) if you need to change the ids in the future you have to update multiple tests, and 2) it’s not very clear from first glance what you’re attempting to accomplish in a given test due to the Espresso calls. So now let’s look at the same example, this time using Screen Robots.

Notice how the test method is more succinct and more easily conveys what we are trying to do, namely login with a given username and password and then make sure that it was a success. This includes the code for our LoginScreenRobot. This allows us to have a thin abstraction layer over the Espresso calls by extending our base ScreenRobot class. Hope you found this short testing tip helpful!

Next Page »

Follow Me

What engineering leaders need to know from this year’s Google I/O

I didn't intentionally aim to create a rhyming title, but there you have it. Each year, I look forward to Google I/O like a kid going back to school. This year … [Read More...]

Talk: The Real MVP

You have an idea for a new app. You've secured buy-in from the business. What's next? The MVP. But what does it take to ship a new app these days? What are the … [Read More...]

Categories

  • Android (55)
  • Career (2)
  • Communication (4)
  • Flutter (1)
  • Git (4)
  • Gradle (4)
  • Grails (23)
  • Java (8)
  • JavaScript (6)
  • Kotlin (17)
  • Life (4)
  • Public Speaking (23)
  • RxJava (1)
  • Software Development (7)
  • Twitter (3)
  • Uncategorized (11)
  • Video Course (5)

Copyright © 2023 · Beautiful Pro Theme on Genesis Framework · WordPress · Log in

 

Loading Comments...