Y
Y
Yaroslav Kornilov2017-05-09 15:30:16
Software testing
Yaroslav Kornilov, 2017-05-09 15:30:16

Why is testing necessary?

The general opinion is that the tests are good. Tests are different and serve different purposes. TDD is recognized good practice..

Nowadays, writing tests is not just a sign of good taste, but one of the requirements that apply to the code.

Why? I'm not against TDD, but isn't it redundant to develop EVERYTHING through this methodology. What are the main arguments in favor of TDD?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
azShoo, 2017-05-09
@yaroslavkornilov

The problem is that developers can't write error-free code.
Moreover, in any complex software systems, when you make any changes, it is too difficult to understand how this will affect other parts.
In order to minimize the search for these bugs and speed up their detection, unit tests are written.
TDD is about writing tests before the code.
Why is it necessary? Because this approach helps to better structure the necessary functionality in your head before writing the code itself.
This approach avoids overcomplicating the code, because the "tests first" approach does not allow you to write a bunch of complex code without checking the correctness of its work.
There are enough pluses.
Now about whether TDD is always necessary.
TDD is not always necessary, as well as beautiful, productive and correctly working code.
Sometimes, you have to put an end to an MVP, test a business idea, and get on with your life. In this approach, 20% of the time spent on units is an unaffordable luxury.
Sometimes, you write a system whose complexity is such that it is not possible to keep in mind the state matrix of even one module. And here already without unit tests in any way. This is where TDD comes in handy.
Summarizing. TDD is a great tool. It allows you not to put off writing unit tests until later, to achieve good coverage and, most importantly, to control changes made to the system. Any unexpected branch of behavior will cause the tests to crash.
Like any tool, TDD is good when you apply it in a timely manner, correctly and for its intended purpose.
Writing tests when production is on fire and the company is failing is a bad idea. Common sense is needed everywhere.

@
@programrails, 2018-10-23
_

I personally think that the tests are an example of typical Western hypocrisy - like in Andersen's fairy tale "The Naked King". Tests are bullshit (more precisely, bullshit). The usefulness of tests is fictional. The tests were invented in the West - and they are alien in spirit to the Russian people - due to their monstrous (typically Western) hypocrisy. Supporters of tests are trying to say something so unintelligible there (in defense of tests) - but no one is in a hurry to believe them - hence, in fact, this question appeared on this forum - if the usefulness of tests was real, people would not ask why they are needed - but just use them. All those who advocate tests - I think, only obediently repeat quotes from Western textbooks - instead of presenting their own thoughts. Certainly,
Where, tell me, is there convincing, irrefutable evidence of the need for tests as such? They are not here. Instead, it is proposed to simply take a word for the "usefulness" of the tests. In addition, writing tests takes a lot of time and is itself a source of errors. It is much faster and more efficient to simply test this or that functionality by hand - than to write a test for this - as a rule, in an extremely inconvenient, clumsy and buggy testing language.
Writing tests BEFORE writing code is generally the TOP of absurdity. Is it really not clear HOW unnatural this occupation is? It's just some kind of game. Even the Western authors of testing textbooks themselves write about this - I read several Western textbooks on testing, trying to find at least some sense in tests - they write that BDD is good in no more than 20% of cases.
Use tests as protection for the future - "if something breaks with new edits"? Well, excuse me, isn't the price too expensive for 90% of projects? Yes, maybe on some million-visited site this is economically justified - but on the vast majority of sites - hardly.
And in general - even if the idea of ​​test automation is reasonable - why do you need to SPECIALLY manually write tests? In the best case, it should be done like this: you test some feature with your HANDS - while the program AUTOMATICALLY remembers the entire sequence of manual testing actions (and then reproduces it if necessary). That's the only way it's supposed to look like. I'm exaggerating a little, of course - but the bottom line is that it's insanely absurd to write tests by hand - spending a lot of time on it and thereby generating new errors.
In short, for myself, for the time being, I personally decided this: write tests only for Western customers - so that their souls are calm. And to make the tests as believable as possible at the same time - giving them as much as possible as a supposedly really necessary and useful thing (from the point of view of the Western mentality). Here is my purely practical recommendation. They have a lot of idiocy in the West that is not understandable (and alien) to the Russian people - and this is one of them.
So I really sincerely do not understand why tests are needed - and I think that they are not really needed - but are needed solely to mislead Western customers - and for nothing else. In any case, in the (ridiculous) form in which they (tests) exist now. I test my code by hand - and this is much better and more efficient than tests. Yes, I'm not saying that I don't test my code - I definitely test (and how could I do without it) - but only with my hands. Maybe in some cases it makes sense to write a test - if it is difficult and long to reproduce the test-verification sequence of actions with your hands - but this is an exceptional case. The Western requirement to cover the code with tests under 80-90% is generally complete nonsense - thoughtless and stereotyped-stupid. After all, they are also not seven spans in the forehead - and most importantly,
I am against tests (in their current form). Moreover, I am against TDD. But I'm not against testing - but only manual.
State your arguments - but only YOURS, and not read somewhere.

D
Dimonchik, 2017-05-09
@dimonchik2013

main idea:
1) the program should work as it should;
2) the program should not work in a way that the program does not need
- read "program functionality"
without tests with (2) , and with rarely used functionality (1) surprises begin, and surprises affect money

K
kn0ckn0ck, 2017-05-09
@kn0ckn0ck

First you need to separate the flies from the cutlets:
Obviously, one complements the other. For example, tests for checking boundary values, for data variability, for integration with data sources (database integration, integration via API, etc.), have nothing to do with TDD, but are extremely important.
It is known that test-driven development usually takes twice as long. On the other hand, try to decide what percentage of test coverage is enough for you to produce a quality result?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question