📜 ⬆️ ⬇️

Test infected

Everything, everyone will write tests


3 years have passed since I saw my first red strip. What jerked me to start writing tests is no longer important. I started collecting information, re-read the entire wiki.agiledev.ru and solemnly launched my first test at SimpleTest . Of course, these tests were terrible, and the architecture too (in my current understanding). Then I probably caught most of the mistakes , but I had a wonderful time :)

Then I switched to PHPUnit - it was just interesting how it differs from SimpleTest and what is so tricky about it.
And lime - disgusting. What are the guys from symfony got into it like that? I understand the branch 1. *, legacy and all that. But 2.0 could be started with PHPUnit.
Yes, it was interesting to me. I actively wrote tests, even honestly tried to do it before writing code. Something did not work, I read various articles on the topic, as it should, and do not write tests, re-read wiki.agiledev.ru. But inside something was clearly missing.

Then Martin's Rapid Software Development book came into my hands (as always, by chance, and maybe naturally, for someone who has the Path ).
This uncle infected me with Ajile, showed what a real OOP is and gave a good kick in the direction of TDD. I still somewhere in the archives is the version of the program for calculating the number of points for the game of bowling, written using TDD (who cares, the link at the end of the article).

Since then, I have become different :) A core and self-sufficiency appeared in me, now I didn’t have to read other people's articles to see shortcomings in my code and tests. Like Miyamoto Musashi, I could learn the truth without the help of teachers.
Now my code is shit too, but now I am aware of this.

And only I was about to ascend to heaven, like Kent Beck , showed me such a focus, which I am delighted about so far. Have you ever written a framework for testing through testing using the same framework? That is, you write the code with which you write it. I tried - it is an unforgettable pleasure. Kent Beck recommends that you start learning a new language like this - write your xUnit in a new language. Ruby is waiting for me.
')
In the same place, at Beck, I met the term "test infected". So, I'm contagious :)

Why do I write tests


Because I'm paranoid and afraid of everything. When I wrote the test, I am sure that:
1. The program works exactly as I expect (each programmer always checks this, only in different ways, and not always in the most efficient way).
2. You can make changes to any part of the system, and at the same time nothing will break. Or I will immediately find out about it and easily fix it.

Therefore:

Way

How to write good tests? If you have a Path, it is a matter of time.
Here, something like that .

As a conclusion


A small list of references:Problems for those who want to have some fun:

Source: https://habr.com/ru/post/86364/


All Articles