My friend Parimala Hariprasad gifted me the book Essential Skills for The Agile Developer, authored by Alan Shalloway, Scott Bain, Ken Pugh, and Amir Kolsky. Thank you, Parimala, for gifting this book. I'm experiencing the value of this book and using it.
In this post, I'm sharing the content shared in Chapter 3 of this book. It is about Testability and how it improves the code quality.
Why this Blog Post?
I continue to read Software Testing literature. I understand the below as one of the primary key skills for a Software Test Engineer practice:
- Identifying the Testability attribute in the system
- Mapping and classifying how the available Testability attribute can be used in Tests
- Asking for the Testability attribute
- How easy it is to test?
- what factors make it easy to test?
- how does it make it easier?
- how does it bring the deterministic character?
- how can I isolate the observations with my analysis with the help of deterministic character and aid added?
- By a Test Engineer's
- awareness, experience, learning, applying the skills, and more
- In a given context
- time, people, environment, availability, and more
The book I mentioned here gives another perspective from the Computer Programming literature. It talks at the fundamental level and I see this is important to understand for we Test Engineers. Soon in the coming days, we Test Engineers will be working and testing in these layers of product development.
In the next section, I will share the lines from the book as is in italics and blue font color word. The credits are to the authors of this book. I'm taking the text as it is from this book. And, I will share my interpretation for the same and see the relativity of Computer Programming and Software Testing literature.
Note: The credit is to James Bach for the Testability definition used above. I added "the tester and context" to it as these two influence the Testability and outcome of using the Testability to a greater extent.
Testability and Code Quality
The authors of the book say, "testability is highly correlated to the code qualities we want to manifest, in particular, loose coupling, strong cohesion, and no redundancy." Further, they illustrate how one remarks at the start of testing one's code by saying the below:
I can't test this code; it does too many things that are so interwined -- weak cohesion
I can't test this code without access to dozens of other things -- excessive cohesion
I can't test this code; it's been copied all over the place, and my tests will have to be duplicated over and over again -- redundancy
I can't test this code; there are too many ways for external objects to change its internal state -- lack of encapsulation
Then I read this line from the authors, "Gee, I wish they had thought of how this code was going to be tested while they were writing it!". That's a question that every one of us has to ask ourselves for the work we deliver and not just for the programming.
Alan Shalloway says he is kind of slow sometimes because it took him some time to realize this -- I should consider how my code is going to be tested before writing it!
Testability is related to loose coupling, strong cohesion, no redundancy, and proper encapsulation. Another way to say this is:
- the tighter your coupling, the weaker your cohesion;
- the more your redundancy and the weaker your encapsulation, the harder it will be to test your code
I and Testability
Relating the Literature and Interpretation
- internal aspects of how it is programmed and to test the same easily in isolation, and in integration for the context while being deterministic
- It will be an obvious experience to a tester when it is difficult to speculate and pull a particular observation with more information for a feature or a user flow
- For example, if the Refresh Token is used along with Auth Token everywhere, then it will be tough to isolate when Refresh Token is used and when the Auth Token is used
- I could not test the mobile apps as I needed data
- Certain data came from a portal that is also under development and depends on APIs to work
- APIs would be under development till the last day of release and did not deliver the endpoints to the portal and mobile apps team
- In one project, I had to login each time to see the status of a session
- All tests were programmed in a way that I should login each time
- The test team used the login function in every test and it was duplicated
- When signed in, the Auth token got changed which lead to difficulty in debugging and isolating the problem
- My team had a tough time when started to use an existing automation
- It had public access modifier for all methods in all packages
- The team picked up and authored more tests that changed the data and states
- This led to any object of a method to modify the data or state; it was not supposed to be modified at all
- The debugging led us here and it was not a problem with the product
- It was the problem with the product's automation code and how the tests changed data and state; it was in turn used in other tests
No comments:
Post a Comment
Please, do write your comment on the read information. Thank you.