Contained in: Android Test-Driven Development by Tutorials
patterns
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Architecting for Testing
Jul 21 2021 · Chapter
…team, like managers, QA testers, analysts and designers. Reusable abstraction: Reusability saves time. Later in the chapter, you’ll see that you can reuse patterns within different parts of an app, across different apps as well as on other platforms. You’ll also see that you can use architecture patterns…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Integration
Jul 21 2021 · Chapter
…dependency many integration tests have on the Android framework and how to handle it. Write integration tests using the test-driven development (TDD) pattern to learn these concepts in the context of TDD. Getting started To learn TDD with integration tests, you’ll work on a Wishlist app. With this…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Introduction
Jul 21 2021 · Chapter
…enough about Kotlin that you’re comfortable working with it. Although it’s not required, it’s helpful to have an understanding of design patterns, dependency injection and app architecture. Whether you’re new to testing and TDD, or eager to apply your existing knowledge to your apps…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Common Legacy App Problems
Jul 21 2021 · Chapter
…fully understand. If you are new to the project, you may be trying to figure out how everything works. One common anti-pattern is have a developer that is new to a project get familiar with it by adding tests to an untested component of the application. That…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
The Testing Pyramid
Jul 21 2021 · Chapter
…pyramid shape. Remember that tests in the lower layers are easier to maintain and run faster. So you should avoid the following anti-patterns: Ice cream cone or Inverted pyramid: The team is relying on lots of UI tests, having less integration tests and yet fewer unit tests. This type…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
What Is TDD?
Jul 21 2021 · Chapter
…toaster") if (result?.contains("toaster") == true) { // 2 print("Success\n") } else { // 3 throw AssertionError("Result did not contain query") } Again, you see this familiar pattern: Call the getSearchUrl() function with a String passed in, storing the result in a variable. If the result correctly contains the query, print the success…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Introduction to Mockito
Jul 21 2021 · Chapter
Learn what mocking and stubbing are and when to use these techniques. Write more unit tests using the test-driven development (TDD) pattern to continue testing state, and a way to also verify behavior. Why Mockito? If you remember from a previous chapter, whenever you create a test, you must…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
User Interface
Jul 21 2021 · Chapter
…button that makes a new joke appear, so the first test you’ll add checks if this button is visible. Following the usual pattern, this test will have set up, actions and verifications. Start with the setup. Create a new test function with the following stub: @Test fun onLaunchButtonIsDisplayed() { declareMock…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Refactoring Your Tests
Jul 21 2021 · Chapter
…didn’t finish out your test cases for your ViewCompanionViewModel to test the other data elements, add tests following a red, green, refactor pattern. The tests you did for your SearchForCompanionViewModel missed a lot of data validation and edge cases. Follow a red, green, refactor pattern and try to cover…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Unit Tests
Jul 21 2021 · Chapter
Learn what unit tests are and what are the best places to use them. Write unit tests using the test-driven development (TDD) pattern to learn these concepts in the context of TDD. Throughout this chapter and Chapter 7, “Introduction to Mockito” you’ll work on an application named Cocktail…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Testing Around Other Components
Jul 21 2021 · Chapter
…normal permissions, there is nothing you will need to do other than include them in your app’s manifest. Signature permissions follow a similar pattern. Things get a little bit more involved when working with dangerous permissions. To understand this, let’s look at an example that uses the CALL…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
What Is a Test?
Jul 21 2021 · Chapter
…application that is working correctly, but could use some refactoring to use a new library, break things up to follow a more readable architectural pattern, etc. A good test suite will provide you with the confidence to make those changes without having to do time consuming manual QA regression test…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
Testing the Network Layer
Jul 21 2021 · Chapter
…match some of these things, such as how you used both Faker and Mockito for your last test. There are some patterns, many of which you see in this book, that guide your testing decisions. There are also some restrictions from the libraries themselves on how they can be used…
Android & Kotlin
Chapter in Android Test-Driven Development by Tutorials
High-Level Testing With Espresso
Jul 21 2021 · Chapter
…part of a RecyclerView. In summary, your app has the following traits: It does not follow a MVC, MVP, MVVM, or MVI type of pattern. Looking at the app as a whole, it has one main external dependency on the Petfinder service. Like many legacy apps, it has some coding/architectural…