Despite the fact that modular testing technologies have existed for 30 years (in 1989, Kent Beck wrote the article “Simple Smalltalk Testing: With Patterns”), however, not all programmers own this technology and not all companies have made automatic testing part of their corporate culture. . Even despite the obvious advantages of automatic testing, behavioral resistance is still quite strong. Anyone who has tried to implement automated tests knows that there will always be some reason why this could not be done.
From my personal experience of introducing reliable programming techniques in my company, in companies that I advised, communicating at conferences, as well as from publicly available sources, I formulated typical objections and resistances that impede the introduction of an automatic testing culture.
I grouped all the objections into a pyramid of reliable programming, which includes four levels:
Why do you need such a division? Because the problem of one level is solved by methods of the same level or by methods of a higher level. For example, if it is not customary in an organization to write automated tests (the problem of professional culture), then this problem cannot be solved by describing the testing business process in detail (“management” level) or setting a modern framework (“technology” level). I give a guarantee that in a week no one will write tests, regardless of the approved business process.
This statement I heard from a beginner or overly confident programmers.
Of course, once written function can not break by itself. But here it is important to understand that over time, the program may require support, the introduction of new functions or additions to existing functions. The complexity of the programs - the number of classes and dependencies between them - is quite large, and with time, after introducing another new function or improving an existing one, an error will occur sooner or later. An automatic test would reveal such a regression.
In addition, often such an objection can be heard from novice programmers who have no concept of testing. For example, only crashes are considered breakage, not functional errors.
At one of the interviews that I conducted, the following dialogue took place:
- Do you have the skills of automatic testing?
- No, I wrote simple programs, there was nothing to break.
- What is your motivation to change jobs?
- I want to write complex applications.
I know very well how this ends. The programmer is trusted to develop a more complex program, but he doesn’t know the methods of automatic testing, cannot test the application qualitatively, and cannot cope with the scale of the project, which will result in disruption of the project, cost overrun in the development budget, loss of reputation. Because I personally supervised projects where I could not cope with the scale of the project and overwhelmed him precisely because of the lack of automatic tests.
Automated tests are the only source of operational and objective information about the true quality of a software product. In other words, behind the programmer's back there is always an overseer, who at any time can report to the management how well the programmer does his job. Automatic tests allow us to link the productivity of labor not with closed tickets in Djir, but with the true quality of the software product. And here you need to think about how to write reliably, so that each successive code change does not break existing functions. That each new function worked not only in the scenario when everything is good, but also correctly handles errors.
Responsibility is a voluntary commitment to ensure a positive result of labor. The employee accepts this commitment because of its nature and education. Unfortunately, due to the cultural and professional crisis, not every programmer is willing to take on such obligations.
People who are not very familiar with how software development takes place may have a negative attitude towards developers who mention some kind of bugs.
- Let's cover the app with automatic tests.
- What for?
- To make sure everything works correctly and there are no errors.
- Do you write with errors? Do you have low qualifications? Write immediately correctly without errors.
- Yes, but everyone makes mistakes ...
- But the friend company XYZ said that they have top programmers who write without errors!
Thus, the development of tests is difficult to “sell” to customers who are not technically savvy. As a result, the management is forced to develop a project without automatic tests, which leads to known problems.
At first glance, this thesis seems fair. Writing tests really takes a lot of programmer time. But programmers and management do not take into account that the total product development time includes not only programming, but debugging and support, as well as the huge cost of manual regression testing after making corrections.
Automatic tests have several functions:
In one of the organizations that I advised, the manager resisted the introduction of an automatic testing culture:
- But after all tests to write for a long time! We will not meet the deadlines!
- Do you have mistakes that you have been looking for and correcting for a very long time?
- Yes, there are.
- What is the most difficult case?
- We were looking for one mistake for 80 hours.
- 80 hours is two weeks of work of the programmer. If you spent even a whole week on test automation, it would save you months of diagnosing and debugging your application!
In our organization there is a postulate: “To write a program with tests twice as fast!” And this postulate is not discussed. Only factor 2 is discussed - sometimes both 3 and 4. And some projects are simply impossible to complete without proper automated testing (see a collapsed project).
At first glance, the separation of specializations for testing and programming seems logical.
But let's look at the shortcomings of manual testing:
Moreover, some types of tests can not be performed in a reasonable time, because the number of combinations of formats and different test scenarios is very large. For example:
Due to the crisis of education in universities, there are no disciplines for automatic testing anywhere. There are very few such courses in commercial IT-schools. And the existing courses are superficial and of poor quality. Therefore, I often met a stupor with programmers: they do not know how to test non-trivial applications (more difficult than 2 + 2 = 4).
In fact, the science of testing is quite extensive. For example, not every programmer will immediately answer the questions: a) what is testability? b) what is controllability and observability? c) what design patterns improve application testability? And so on.
It is very difficult to test what is unclear how it looks. In other words, without pre-formulated requirements for the application, the programmer cannot understand what is expected of him.
The peculiarity of some projects is that they are developed using the Minimum Viable Product technology, which in other words can be described as: “Let's do at least something in minimum time and minimum budget,” and the programmer is considered by the customer or management as an analyst, designer, architect, programmer and tester in one bottle. With this approach, the formal stage of designing a software system is excluded: the definition of business logic, the subject area, the interfaces of the components, as well as their internal organization of their relations between them. There is no formalized architecture, there are no interfaces, there are no prescribed business processes - it is not clear what to test, through which interfaces and what is the expected result.
Testability is a project property that says: how easy it can be tested. Testability is determined by two other properties: controllability and observability. Manageability is a property that determines how easily an application can be entered in the desired state for testing (to fulfill preconditions). Observability - how easy it is to consider the state after the test, compare it with the expected one.
For example, two-factor authentication using SMS is very difficult to test automatically, because the function of receiving SMS is beyond the scope of the automated testing environment. Such a system is not testable.
Facing an untestable system, the programmer gives up and avoids testing such a system.
One of the unobvious resistances is the preparation of test data and standards. For example: the initial state of the database on which testing is performed. The preparation of test data can take a lot of time and routine work, therefore this work is considered ungrateful and uninteresting among programmers.
Decision:
During the development of the project to it may change the requirements (clarification, change). Or internal refactoring may occur, which will change the class interfaces. As requirements change, the acceptance criteria for a particular function will change, and with them the tests. At some point, the programmer may refuse to service the tests - that is, to keep them up-to-date.
Decision:
There is no doubt that software must be reliable: exceed consumer expectations. Automated tests, though not the only, but an important component in the development of reliable software.
I formulated typical objections and obstacles to the implementation of automatic testing, which I encountered personally in my organization, as well as in those organizations that I advised.
The article outlines only the problems and barely affects their solutions. In general, the strategy for solving the mentioned problems seems to me like this:
The most important thing that I managed to understand is that the problems are at different levels: technological, methodical, managerial and cultural. And they need to be addressed at appropriate levels. It is very difficult to implement automatic tests if the programmer is not trained in methods of testable design or if the management does not support a culture of reliable programming in the organization.
I will be grateful to examples from your practice, how easy or how hard it was to implement automated tests in your organization. What problems did you face? How did you solve them?
Source: https://habr.com/ru/post/418491/
All Articles