1

Topic: Tests steady up the time of performance

Good afternoon, colleagues. Impart experience, pls. As you do tests steady up the time of test performance.... As you arrive, if the result of operation of tested procedure depends on time of carrying out of the test (i.e. in procedure in # becomes DateTime. Now or in SQL becomes GETDATE ()). As you provide that at all time different results tests work. There is any standard uniform approach? Judgement: to Write difficult enough  which check everything did not change that does not depend on time, and all changed also in the correct image that it depends on time is terribly troublesome. Whether it is impossible "to stop time" and to write the test as though time does not leak absolutely? It strongly would simplify life. It would be possible to compare simply entirely "the instant pictures" states. How you arrive?

2

Re: Tests steady up the time of performance

Hello, Pek2014, you wrote: P> Good afternoon, colleagues. Impart experience, pls. P> As you do tests steady up the time of test performance. P> as you arrive? Obviously, to carry out a part which is responsible for obtaining of current time and a time delay in a separate component and to presoak it

3

Re: Tests steady up the time of performance

Hello, Sshur, you wrote: P>> As you do tests steady up the time of test performance. S> it is obvious, to carry out a part which is responsible for obtaining of current time and a time delay in a separate component and to presoak it I Want to specify: you so do? Or you it purely theoretically? After all this component all who needs current time should use. It should be the decision at level of all project, is centralized?

4

Re: Tests steady up the time of performance

Hello, Pek2014, you wrote: P> As you arrive? I do not use DateTime. Now or GETDATE () in BL/procedures, or I try to avoid. For tests - an exterior/test source of time setting for example certain . But in my practice - these of date/time though were "now" - but all of them equally were parameter of transactions BL. Moreover - costs it will be defined - "now" is when? Request setting in queue, the beginning of its handling and other. Whether it should be observed  this time at different stages of handling of request. Well i.e. for example for one request it is fulfilled DateTime. Now, GETDATE () and one more time DateTime. Now. And so - 3 different values - and not always differ they only milliseconds.

5

Re: Tests steady up the time of performance

Hello, Pek2014, you wrote: P> I Want to specify: you so do? Or you it purely theoretically? P> after all this component all who needs current time should use. P> it should be the decision at level of all project, is centralized? Well. For C# it is completely not difficult to implement TimeService and with method GetCurrentDateTime () and to track that all under the project it used. Well actually if the person writes units-tests at it at once there will be a question "how to check that date the leaking has been put down?", and the answer already is.

6

Re: Tests steady up the time of performance

Hello, fmiracle, you wrote: F> Hello, Pek2014, you wrote: P>> I Want to specify: you so do? Or you it purely theoretically? P>> after all this component all who needs current time should use. P>> it should be the decision at level of all project, is centralized? F> well. For C# it is completely not difficult to implement TimeService and with method GetCurrentDateTime () and to track that all under the project it used. Well actually if the person writes units-tests at it at once there will be a question "how to check that date the leaking has been put down?", and the answer already is. Clearly. Thanks. And if you do not have possibility to affect the project as a whole?

7

Re: Tests steady up the time of performance

Hello, fddima, you wrote: P>> As you arrive? F> I do not use DateTime. Now or GETDATE () in BL/procedures, or I try to avoid. I will try to collect all possible decisions. A method 1. To track (to oblige, enter a rule) that there was no "secret" usage of current time. To those procedures which result depends on current time, it is necessary to transfer this time explicitly as parameter. Then at testing we will have a possibility to transfer time as parameter that is the result of the test becomes fixed. A method 2. To do a uniform source of current time and time. All to oblige to use only this component for obtaining of current time. A component to presoak and so to control time that is result of the test becomes fixed. A method 3. In tests to write such  which consider that some results should change and the correct image to correlate with current time, and others should be . A method 4. To execute tests for a server () on which system time is forcedly installed. If you cannot solve for all project as a whole, you still have only two last methods. So?

8

Re: Tests steady up the time of performance

Hello, Pek2014, you wrote: P> There is any standard uniform approach? P> as you arrive? Everything that should , is written as pure functions / classes / methods. But from the very beginning it is necessary to do it, certainly. Already written dirty code on-nemnogu breaks on dirty making and pure. It is tested only pure, certainly. But it is occasionally very heavy, especially if dirty functions in  .

9

Re: Tests steady up the time of performance

Hello, Pek2014, you wrote: F>> Well. For C# it is completely not difficult to implement TimeService and with method GetCurrentDateTime () and to track that all under the project it used. Well actually if the person writes units-tests at it at once there will be a question "how to check that date the leaking has been put down?", and the answer already is. P> it is clear. Thanks. P> and if you do not have possibility to affect the project as a whole? 1. To make for usage in the classes for which you and write the tests. 2. To try to affect the project as a whole if there is a desire to change the whole world to the best

10

Re: Tests steady up the time of performance

Hello, Pek2014, you wrote: P> I Want to specify: you so do? Or you it purely theoretically? P> after all this component all who needs current time should use. P> it should be the decision at level of all project, is centralized? Yes, no, yes there are technologies which provide correspondence of the written code to the rules accepted in the specific organization - TDD, code review. Without such service it will be impossible to write tests. Without tests the code should not transit the code . At question origin "and how to write the test" to the beginner existing service should be shown. If he guesses to write the copy without asking - besides on the code  the correct variant should be shown