I'm teaching a capstone (the final class in an undergraduate program) software engineering course in which we are developing Android applications in Java. I consider test-driven development and unit testing important but am having trouble coming up with Android-related assignments, since so much mobile programming is about user interfaces and synchronization, neither of which are ideal for unit testing.

The only thing I've thought of is that they could unit test a database running on Android, which would also let me introduce mocking, but that doesn't sound very interesting.

Any suggestions of a small but interesting Android project suitable to TDD and unit testing?

  • $\begingroup$ Who is the course for?: What age? What level are they at? What experience? $\endgroup$ – ctrl-alt-delor Feb 9 at 17:25
  • $\begingroup$ Capstone means it's the final class in a curriculum, an undergraduate program in this case. $\endgroup$ – Ellen Spertus Feb 10 at 0:47
  • $\begingroup$ I'm not quite sure how an Android oriented codebase differs from the norm in regards to unit testing. Am I missing something? Isn't this just a matter of testing whatever business logic the code contains? $\endgroup$ – Flater Feb 13 at 14:29

I assume that there is some logic in the app, somewhere. Hard for me to imagine it otherwise.

If you build the client side with a Model-View-Controller architecture, the testing can be done on the model (as is most natural) and possibly on the controller.

If the server side is also built by the students, then it may also require logic beyond data access. So that can also be tested, either directly on the server side, or with mock clients. Maybe both.

I admit, though, that I don't build these things.


Tic tax toe.

Begin game. Test model state is:


Move(x, 1, 1). Test model state is:


Scoring bowling.

Begin game. Test score is:


knock down 3 pins. Test score is:


Knock down 3 pins then 7 pins. Test score is:


Unit testing is orthogonal to android. Nothing about android keeps you from unit testing. You just have to insist on doing it. That means using a design that accommodates it.


I have written a small game for Android, which I published on GitHub.

It's a board game, and I have written unit tests for all important parts of the program, especially for placing stones on the board. These tests are in the app/src/test folder.

Since I have translated the app into several languages, I have put the string messages into Android-style XML files. To test whether these string templates are filled with the correct placeholders, I had to test them in a more realistic environment. Therefore these had to go into the app/src/androidTest folder.

The code is already more than a year old and I'm still satisfied with it. Therefore I think it makes a good example.

New contributor
Roland Illig is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

I think form validation is a good example.

  • 4
    $\begingroup$ This answer is very short, but has potential. Can you tell us more? $\endgroup$ – ctrl-alt-delor Feb 9 at 17:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.