1

Topic: Pluses of the best methodologies a testing unit.

2

Re: Pluses of the best methodologies a testing unit.

3

Re: Pluses of the best methodologies a testing unit.

Hello, UberPsychoSvin, you wrote: UPS> There is here an IT evangelists which push about the correct methodologies of testing. All of them for a long time already on hearing: test-driven development, testing of minimum units, with  dependences, on one  on the test, etc. UPS> If to write this business through  : TDD c RGR, OAPT, Damp over Dry the Real world is more difficult than any methodology. They only an example as it is possible to arrive in an idealized case. And for different methodologies different idealization. It is necessary to be guided by common sense. UPS> that in the course of a spelling is born such  tests UPS> Minuses are obvious. On 14 code lines without logic, 97 lines of tests, by sight not so useful already were born. The correct question - if you suppose their useless and it is not necessary  to write all this. UPS> before any change of a tested method, it is necessary to shovel these mountains of the code. , one of assignments of tests is the help at refactoring, correction, optimization and other changes, therefore on idea, at change of the code tests should either remain former, or change not so strongly. Otherwise their meaning is partly lost. UPS> and in what pluses? Look, here you resulted a code piece. And how you check its serviceability? It is possible not to check at all.  and it is fine, at once gave . Minuses it is long iterations between you and  (you already were engaged in other piece, and they to you a heap of bugs on old), it is a lot of time for search of causes of error (any bugs can and on storage you will repair, and it is necessary to search for something) etc. the majority of us can continue the List. It is possible to check, how in the ancient time, in a head - but programs now have the big structural complexity, plus any exterior pieces - as a result it is labor-consuming and is not productive, except for separate pieces of the code. It is possible to check up in the old manner - launched the program, submitted the input data, checked up results. Minuses - it is labor-consuming on everyone  to drive such checks, it is difficult also laziness at each change to check all variants of the input data, for "the code which interacts with exterior pieces" it is necessary to do the test environment with these pieces. In components if you drive all the program entirely - difficult to estimate operation of a separate piece of the code. And if you write helpers, for check of a separate piece - that it as a matter of fact and is tests, simply used time, you throw out them. It is possible to do "on modern" - to replace the last variant with tests which imitate the test environment, drive checks on all variants of the initial data which you can invent and do it automatically on everyone . A minus - it is necessary to write the code of these tests. Plus - is reduced time and labor input of search of errors, not so the test environment is strongly necessary and it is possible to correct rather without serious consequences the code. It is necessary to tighten productivity or to replace library - on fast rewrote, ran tests, corrected, ran - it is made. Tests it simply one of methods of validation of the code. If their pluses outweigh minuses - write. Do not outweigh - do not write. The unique moment, I advise to make a separate branch in any project and in practice to try to use tests to those parts which now razrabatyvajutsja/correspond. Here as with monitoring systems of versions, experience is important what to store the code in vcs more conveniently than not to store.

4

Re: Pluses of the best methodologies a testing unit.

Hello, UberPsychoSvin, you wrote: UPS> Minuses are obvious. UPS> and in what pluses? Plus that when you will write tests, will break the code more difficult. And besides the code that will be tested, instead of is simple because to the programmer was thought that all is normal. And a minus at all in volumes of tests. When the program at it is developed the architecture changes. Hence tests should be rewritten, but there will be an essence of that they check, after all without them it will be lost. That Mahlo that supporters TDD describing them in books committers Agile so they also beforehand think over possible changes. Here in what a trick as explain in books, then you tests for the program do not write, so write them before code writing. To, instead of right after a spelling. That is the programmer yet did not start to write the operating code, and the test is already ready and try to be laid down in it. As a result the main favor will be derived by the high-level programmer, almost the clairvoyant. Normal which does as can on an extreme measure in the beginning receives rigid . That it to remove, that is necessary  TDD long time, and, someone learns, and someone is not present, and someone at all does not begin. So here a question here in what: 1. Whether It is necessary a unit-testing? 2. And if nevertheless it is necessary, when it to do, before writing of the code or after? And if it is not necessary, then:

5

Re: Pluses of the best methodologies a testing unit.

6

Re: Pluses of the best methodologies a testing unit.

Hello, UberPsychoSvin, you wrote: UPS> There is here an IT evangelists which push about the correct methodologies of testing. All of them for a long time already on hearing: test-driven development, testing of minimum units, with  dependences, on one  on the test, etc. I am restricted to integration tests, a unit tests - only for difficult algorithms. And  let go wood.... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

7

Re: Pluses of the best methodologies a testing unit.

8

Re: Pluses of the best methodologies a testing unit.

CM> I am restricted to integration tests, a unit tests - only for difficult algorithms. CM> and  let go wood. Words not junior-a, but the husband

9

Re: Pluses of the best methodologies a testing unit.

Hello, Vedmed, you wrote: CM>> I am restricted to integration tests, a unit tests - only for difficult algorithms. CM>> and  let go wood. And then months release ? Simply because about a unit tests the majority of bugs not cunningly would transit the first . For the sad glue code of type "to take a forcemeat ball, to dip in crackers and  on a frying pan" which majority even in quite interesting projects, units-tests will be only  code lines without real favor. Integration tests (that is simply functional, but more high level) catch problems not worse, and to write all of them equally it is necessary. And to draw units-tests (it is unimportant, with TDD or without) to be convinced of that, as eyes visible that is caused A and its result is applied to B... Thanks, I know better methods to waste time for nothing. And here cases when you can not be assured that you subtract correctly the code (objectively estimating the abilities) - the normal programmer himself draws tests to be convinced that all is executed correctly, including typical and marginal cases. But here to this all the spiteful administrative moments which all break float, namely: 1. In enough big heterogeneous command it is impossible to hope for an adequate self-estimation of each programmer. Also is a lot of such which  try , without finishing the part.  from it helps, but it is not strong. 2. Receiving conditional  (or as there consider by galleys) for the code, he does not want to be returned itself to for a long time forgotten code => the administrative violence is required. And then still to understand, how many from already taken place payment to subtract. . Therefore, if there is no well-founded trust to the author it is better to force all these requirements of tests at each level, how much generally probably and does not become covered by other measures (like ).

10

Re: Pluses of the best methodologies a testing unit.

Hello, Vedmed, you wrote: And then months release ? . Simply because about a unit tests the majority of bugs not cunningly would transit the first . A garbage. Tests any a unit guarantee nothing, as from errors of understanding  do not rescue, and even for more primitive bugs too guarantee nothing, as can contain errors.... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

11

Re: Pluses of the best methodologies a testing unit.

12

Re: Pluses of the best methodologies a testing unit.

13

Re: Pluses of the best methodologies a testing unit.

14

Re: Pluses of the best methodologies a testing unit.

15

Re: Pluses of the best methodologies a testing unit.

16

Re: Pluses of the best methodologies a testing unit.

Hello, Vedmed, you wrote: At what here errors of understanding  and a unit tests? To errors of understanding  it is necessary to lift still system taking into account regress. And here regress to check up a unit tests help at the earliest stages. To sense to you that at you there transit all tests and there is no regress if the program does at all what should? Purely interest for the sake of, how many tests in your test model? How many from them automatic? The bad question. You at all did not ask, what value of a program.... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

17

Re: Pluses of the best methodologies a testing unit.

Hello, Sharov, you wrote: S> to Launch tests from under any guest'? Or specially to adjust . The user and with it all to check. Well it already from area devops. In  also put that a unit tests - environment agnostic. All exterior dependences mokajutsja/stabajutsja. Aim a unit of tests - to check up that business of the logician works "as it is necessary" and it nobody broke casually at a fix of bugs-refaktoringe. We follow an example from : var lastUpdateTime = updatesRepository. GetLatestUpdateTime (); var now = timeService. UtcNow; var updates = usersService. GetUpdates (users. Emails, lastUpdateTime, now); It makes sense to write to tests for that that - updatesRepository. GetLatestUpdateTime () - it is caused - timeService. UtcNow; - it is caused - values of time are correctly transferred in usersService. GetUpdates, without confusing places. In the general it makes sense to write under the test for each branch in the code logic business. And only logic business. All infrastructure is wetted. They are written by packs (thousand unit of tests it is elementary in projects on pair ), very quickly (because primitive) and packs are thrown out at large refactorings. Thus they  very quickly, not longer steams of minutes also do not depend at all from . Therefore can be launched both from studio, and before , automatically, and before . In difference from them, integration tests demand specific , as a rule are launched at the last stages CI and some hours can run. Thus check all".  are necessary both those and these. In projects in which the error price is high. A unit tests - for early detection and a fast fix of the most typical errors and misprints. Integration - for final check of all product in the specific environment of a surrounding.

18

Re: Pluses of the best methodologies a testing unit.

Hello, CoderMonkey, you wrote:> it is simple because about a unit tests the majority of bugs not cunningly would transit the first . CM> the Garbage. Tests any a unit guarantee nothing, as from errors of understanding  do not rescue, and even for more primitive bugs too guarantee nothing, as can contain errors. Well against such situations there is a method to demand writing of tests not the author of the code, namely QC employees. Jef239@habr persistently recommended such variant also because testers much more cheaply.

19

Re: Pluses of the best methodologies a testing unit.

Hello, netch80, you wrote: N> Well against such situations there is a method to demand writing of tests not the author of the code, namely QC employees. N>Jef239@habr persistently recommended such variant also because testers much more cheaply. All the same the garbage because 1) errors can be immediate in  2) probability of errors in tests at such approach becomes still above. And still there are various not determined errors against which units-tests too are absolutely useless.... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

20

Re: Pluses of the best methodologies a testing unit.

Hello, itslave, you wrote: I> "the Clever" stub is not necessary. Enough primitive , on one on the scenario. The clever stub is necessary for integration tests. Well type  in a feature, InMemoryDbContextStub, InMemoryFileSystemStub. And all , also fulfilled quickly.

21

Re: Pluses of the best methodologies a testing unit.

Hello, UberPsychoSvin, you wrote: UPS> the Clever stub is necessary for integration tests. Well type  in a feature, InMemoryDbContextStub, InMemoryFileSystemStub. UPS> And all , also fulfilled quickly. And moki/stubs in integration tests generally kill idea of integration testing.

22

Re: Pluses of the best methodologies a testing unit.

Hello, Vedmed, you wrote: "THAT that should" includes including that that did earlier (greetings to regress). And tests show a unit at the earliest stage that the system to see itself as it was expected. The same, as did earlier. But not that should. But who is excited with such trifles? Very good question therefore on it it is possible to judge system complexity and about a process maturity. An idiotic question. Approximately so idiotic, as that idea of Soviet period to measure productivity of a carrier in kilometer-tons.... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

23

Re: Pluses of the best methodologies a testing unit.

24

Re: Pluses of the best methodologies a testing unit.

25

Re: Pluses of the best methodologies a testing unit.

Hello, UberPsychoSvin, you wrote: UPS> But on my observations, in many projects the fair part of the code, interacts with exterior pieces. I.e. about such type: UPS> UPS> public void LoadSubscriptionUpdates (long userId) UPS> {UPS> var users = usersService. GetSubscriptions (userId); UPS> usersServiceRequests. LogServiceCall (userId, users, users. Count); UPS> var lastUpdateTime = updatesRepository. GetLatestUpdateTime (); UPS> var now = timeService. UtcNow; UPS> var updates = usersService. GetUpdates (users. Emails, lastUpdateTime, now); UPS> usersServiceRequests. LogServiceCall (users. Emails, updates. Count, lastUpdateTime. ToUnixTimeStamp ()); UPS> var updatesDal = _dataConverter. ToDal (users, updates, lastUpdateTime, now); UPS> updatesRepository. Add (userId, updatesDal); UPS>} UPS> Here what that the delirium is written. I would make  : public Updates GetSubscriptionUpdates (User user, Time now)//and  to drag on id all successively.//Time always is dragged on top and it is not necessary to torment a bottom . {var subscriptions = usersService. GetSubscriptions (user);// inside GetSubscriptions var lastUpdateTime = subscriptionService. GetLatestUpdateTime (subscriptions);// inside GetLatestUpdateTime var updates = updateService. GetUpdates (subscriptions, lastUpdateTime, now);// inside GetUpdates return updates;} + separately saving public void SetSubscriptionUpdate (Updates updates, Time now) {//var updatesDal = _dataConverter. ToDal (users, updates, lastUpdateTime, now);//the garbage in line above should be  a repository updatesRepository. Add (updates, now);} UPS> Minuses are obvious. On 14 code lines without logic, 97 lines of tests, by sight not so useful already were born. Before any change of a tested method, it is necessary to shovel these mountains of the code. At you the classic - the test checks exactly that does a method [Fact ("Should call GetSubscriptions")] Here such thing means that the correct result reached in another way tumbles down all tests. UPS> and in what pluses? In your case one minuses - the code fragile. In my case all is a little differently. Your tests are never necessary. It is necessary to write absolutely another. The pure context,  DB and correct functions of the job of a state by this most DB is necessary. Anything - the attention - anything  is not necessary! And the test set is received absolutely another, not "xxx causes yyy", and quite normal I will bake [Fact ("Don't update when no subscriptions")] [Fact ("Don't update when wrong time")] [Fact ("Don't update when too early")] [Fact ("Throw exception when subscriopions are invalid")] [Fact ("Throw exception when subscriopions are invalid")] and so on. Tests it is necessary much, yes, it is a lot of! But here under such tests it is possible to check up the specification and to find that is passed, , , obsolete, actually, is irrelevant and . That is, pluses begin at normal design of the code 1. It is less debugging time - the test shows which method was broke off by the first. 2. Errors become known at once - less time  as a whole.  time  - namely this part most  on efforts and time there is less. That is, economy. But it is all at normal design when the decision is projected including Under tests, that is, the code initially . And the most important thing - tests work only when operation began with requirements. Quality is a level of correspondence to requirements. There are no requirements - there is no sense to speak about quality because any shit approaches.