Building an application with testing in mind
So, we now know that testing is important and we've also got to know about the different kinds of testing. But are there any important things that we need to do while building our application so that we are able to test it properly?
Â
The answer to this question is a bit complicated. Although we can easily write the code in any particular manner we desire, and subject the code to testing through a number of procedures, for example, unit testing, it is still better to follow a general set of guidelines so that the code can be tested easily and efficiently. So, let's go ahead and take a look at the guidelines:
- Every component should have one responsibility: For testing to be efficient and to cover all the possible code paths, every component should play a single responsibility. For example, take a look at the following code:
def encrypt_password(password): """Encrypt the provided password. Keyword arguments: Password – The password...