What Should we Unit Test?
When I go to work, I’m afraid of three things. I worry that the new feature I’m implementing won’t work as expected the code I’m tweaking will break functionality that used to work the application isn’t architected in a way that makes it easy for me to adapt it to ever-changing business requirements Automated testing is supposed to help alleviate all three of these fears, but when we’re first getting started with automated testing, it can be difficult to know where to start.…
How we Misuse Mocks for Android Tests
Mocks are a pretty standard tool in our android developer tool belt. The extent to which we should use this tool for unit testing is a complicated and controversial issue.1 Within the Android community specifically, I think that a part of the controversy is due to confusion over the intended use of mocks. More specifically, some android developers seem intent on mocking types they don’t own and on verifying all interactions of a target class with a collaborator.…
Build Variants and Link Seams
This post is just another installment in a series of posts that are a written version of my Florida dev fest talk. Last time, we talked about object seams and how they make our apps more testable. This time, we’ll talk about how link seams help you write more testable apps and how build variants are used to create link seams. What are link seams? “[code] contains calls to code in other files.…
Object Seams and MVP for Testability
In my last post, a continuation of a written version of the talk I gave at Florida dev fest, I tried to give an answer to the question, “What makes apps testable?” The answer: seams. Seams make apps testable, and in this post, I want to talk about a particular kind of seam: object seams. The key insight behind object seams in this: The fundamental thing to recognize is that when we look at a call in an object-oriented program, it does not define which method will actually be executed.…
What makes Android Apps Testable?
This post is a continuation of my attempt to reproduce my recent DevFest talk in written form. …
Why we Should Probably Write More Tests for Our Android Apps
This past weekend, I had the privilege of speaking about writing testable Android apps at Florida DevFest. This post is a written version of one of the major points I made in my presentation. Let’s start off with two descriptions of attitudes towards testing. The first comes from Kaushik Goupal (he’s describing an attitude, not endorsing it): Testing seems to be like going to gym. Everyone feels like “yeah. I should be testing.…
Using Git Submodules Effectively
I used to think git submodules were categorically evil. This was naive, as most choices in software development are about tradeoffs. A part of the reason I had this simplistic view was because of an article called “Why your Company Shouldn’t use Git Submodules.” I took a second look at this article recently and I read the docs on git submodules. What follows are some more nuanced thoughts on how and when git submodules can be used effectively.…
3 Ways of 'Getting to Green'
A part of the TDD work flow is getting a failing test to pass as quickly as possible. This makes sense if we think about how TDD is supposed to help us take smaller steps when we’re writing programs. Beck goes over three ways of getting a test to pass quickly in the fist part of TDD By Example. The first method is to fake it. Just hard code whatever values you need to to get the tests to pass.…
The goal of refactoring During TDD
Red, green, refactor. That’s the TDD flow. That much was obvious to me. However, refactoring is a pretty broad term. There are many reasons you may want to refactor code and as a result of this, I didn’t really understand what exactly was supposed to happen during the refactor step of the TDD loop until I finished the first part of Kent Beck’s TDD by Example. Actually, in the first description of TDD, Beck uses a more helpful description of the “refactor step.…
TDD and Startups
Kent Beck introduces TDD by Example with a little story meant to show the business value of automated testing: Early one Friday, the boss came to Ward Cunningham to introduce him to Peter, a prospective customer for WyCash, the bond portfolio management system the company was selling. Peter said…“I’m starting a new bond fund, and my strategy requires that I handle bonds in different currencies.” The boss turned to Ward, “Well, can we do it?…