Sergey Nivens - Fotolia
Mock tests are best written before you start writing any code. This is a process known as test-driven development (TDD). The idea of being able to write all of your tests after your code is already written is a hard one, and typically you'll end up either missing things or feeling like you're wasting a lot of time trying to cover everything.
One useful tool if you're working on Android mock tests -- after you've already written your code -- is to use a coverage testing platform, to show you where in your code you've missed, and try to write tests for all of those functions.
There really is no shortcut to writing unit tests.
Keep in mind that there are two different types of Android mock testing for your application. First there are unit tests, which essentially help prevent "regression errors" where a new update breaks old code. The other type is end-to-end testing, which helps to detect new issues. End-to-end tests are, in my experience, the most useful tests and fortunately they're one of the easiest types of tests to do. Instead of focusing on specific functionality of code blocks, you're focusing on testing of your entire application. The simplest form of this type of testing is to have a group of testers (preferably ones not familiar with your development team, or code base) and give them the app. Record their interactions and make sure to have them try to do things in the app that you would expect as well as try their own things. After recording a few users, you can write a "script" for users to follow after each significant upgrade to make sure the end-to-end functionality works and is intuitive for your end users.
About unit test scaffolding
Why you shouldn't write unit tests
Dig Deeper on Cloud application development and deployment
Related Q&A from Chris Moyer
Event-driven computing means no IaaS provisioning and no data center to run. Can I migrate all enterprise apps to be event-driven? Continue Reading
What is runtime as a service and how does it differ from platform as a service and infrastructure as a service? Continue Reading
The DevOps model is taking off as cloud adoption grows. But what exactly are the key responsibilities of a DevOps team in the enterprise? Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.