I want to write tests

imageI always read articles about code testing with interest. And I really want to use tests in my projects.
But I can not. I can not find an incentive for myself.

Yes, the tests from the examples are written almost instantly. But is it necessary to write a test for a function
def get_word():
    return 'word'

the question is rather complicated. Writing it will not be a problem, but it will not be tangible.
Write such a test to get the joy of a +1 completed test? I don’t see the point.
To increase test coverage? I don’t see the point.
Just like that? ...

With tests everything is fine, while they are from educational articles. But tests are needed for more complex operations:
For example, parsing of other sites is used on one project. A large amount of textual information and pictures are taken from them, reports on the work done, etc. are sent.
Here for this process I would like to write tests.

But it makes no sense to write small tests for each function. They work so well.

I understand that the previous line is outrageous. But in reality, the function that, for example, downloads the image and saves it in the storage is elementary, and there will be no errors in it (more precisely, these errors are too obvious). Errors appear when using this function (storage is not available, image processor did not work, etc.).
Moreover, testing all of these functions separately does not mean anything - the processor perfectly fulfills a thousand images, the storage can withstand more operations than required. All this, of course, is checked in the function itself, but this does not apply to tests.

It is necessary to check the interaction of all functions.
This is what I want. Run the tests and be sure that a rather complex parallel process is running correctly.
But to write a test for this whole process (created subsidiary processes, downloaded pages, found the necessary information, downloaded pictures, converted pictures, validated data, saved data, checked data for integrity, saved reports, etc.) you need to spend a lot of time .
An error can only happen when functions interact. Moreover, the test data does not verify these vulnerabilities at all (what is possible to test bmp in jpeg files on some sites, but why if the function still needs to be thrown and it will work?).
Huge arrays of test data can be created to test for these errors, but even this is where the problem lies. If the error appears once, then we just fix the function, why do we need to write a test for this error? She will be gone!

It turns out this problem: I
want to write tests, but there is no return from them. Writing time is wasted. Checking what already works does not make sense (based on experience - we do not break what already works. Well, somehow it happened). For each new case, create a test, fix the problem, check? What is the point of this double spelling of the same thing? The error has already been fixed, writing a test that will cover many times more than this error does not work, and checking with single verification data from all possible is not particularly useful. The number of possible errors will not decrease at times. Percentage maximum.

Yes, there is another important factor: customers will not understand.

I can’t tell the customer that the price of the product will be higher due to writing tests.
I can’t put the price for the project higher, the customer will go to competitors.
I can’t help but change the price due to tests, I want to earn something.

The customer does not care about tests, stability, everything except the final result. He can’t be explained that this product with tests will be better than without them, because it will be more stable, scalable, etc. He doesn't care about that. He needs a result. Quickly. And as cheap as possible.

Of course, I hope this only applies to our area - web programming. For systems related to money circulation, systems on which people's lives depend, etc. tests are required, and there customers will understand that they are needed. I believe in it.

Also popular now: