Test-Driven Development
Let's assume that you are tasked with building an activity that displays a calculator with the add, subtract, multiply, and divide options. You must also write tests for your implementation. Typically, you would build your UI and your activity and a separate Calculator
class. Then, you would write the unit tests for your Calculator
class and then your activity class.
Under the Android TDD process, you would have to write your UI test with your scenarios first. In order to achieve this, you can create a skeleton UI to avoid compile-time errors. After your UI test, you would need to write your Calculator
test. Here, you would also need to create the necessary methods in the Calculator
class to avoid compile-time errors.
If you run your tests in this phase, they would fail. This would force you to implement your code until the tests pass. Once your Calculator
tests pass, you can connect your calculator to your UI until your UI tests pass. While this...