Juan-Carlos Gandhi (
juan_gandhi) wrote2020-08-23 09:18 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Entry tags:
TWIMC: tests using random and current time
So, if you think you call a function in your code, and this function returns current time, or a random number... IT'S NOT A FUNCTION. Your code is function of "random number", or "time".
So, if your code is written as something that retrieves this kind of data, to test your code, you should provide that data. Not just today, but try the time, like 10 years from now. As to "random", You provide the randomness. If your code cannot be fixed to behave as a function of those inputs, make your "random stream" or "time stream" not hard-coded, but substitutable. Mockable. And mock it in your tests. MAKE SURE that you don't provide just happy-path data. Provide anything. A sequence of 100 numbers 4 for random. Time that is 10 years from now. Or even 30 yeas from now.
Make sure that your tests don't depend on anything. Because test Must Be Reproducible.
All these things, I know, are obvious to some, and not obvious to others.
So, if your code is written as something that retrieves this kind of data, to test your code, you should provide that data. Not just today, but try the time, like 10 years from now. As to "random", You provide the randomness. If your code cannot be fixed to behave as a function of those inputs, make your "random stream" or "time stream" not hard-coded, but substitutable. Mockable. And mock it in your tests. MAKE SURE that you don't provide just happy-path data. Provide anything. A sequence of 100 numbers 4 for random. Time that is 10 years from now. Or even 30 yeas from now.
Make sure that your tests don't depend on anything. Because test Must Be Reproducible.
All these things, I know, are obvious to some, and not obvious to others.
If you still have questions, ask. But don't argue. Because what I say is math. Unless you have another math (some people do), or another logic (there's plenty of them), please don't argue.
I'd be glad to see how all this changes if logic is e.g. linear.
Re: Is full service test coverage possible with mocks?
Это не ошибка, когда несут ахинею. Это система.
Re: Is full service test coverage possible with mocks?
Зачем ты это сделал?
Re: Is full service test coverage possible with mocks?
Зачем я комментирую ахинею, что ты несешь? Чисто из зрительного зала. Обсуждать с тобой это нет смысла. Был бы ты программист, тогда могло бы иметь смысл. Какое тут нафиг взаимопонимание. Для взаимопонимания нужно понимание, а у тебя полный швах с этим делом.
Re: Is full service test coverage possible with mocks?
Нет.
Зачем ты высказал утверждение, не относящееся к вопросу, который я задал?
> Чисто из зрительного зала.
Ты имеешь ввиду, что прикольно иногда покричать какие-нибудь глупости из зрительного зала?
> Для взаимопонимания нужно понимание,
Да.
> а у тебя полный швах с этим делом.
Из каких признаков ты сделал такой вывод?
Re: Is full service test coverage possible with mocks?
Из той чепухи, что ты нес.
Признаки непонимания
Давай я тебе дам пару примеров признаков непонимания:
1) Когда ты на мой вопрос отвечаешь нерелеватным утверждением -- это признак твоего непонимания.
2) Когда на мой вопрос с запросом более детального объяснения ты повторяешь недоказанное утверждение -- это признак твоего непонимания.
Re: Признаки непонимания
Могу, но не тебе. И не моей кошке тоже.
Я также уверен, что в доказательствах ты столько же примерно понимаешь, сколько и в функциях.
Re: Признаки непонимания
Re: Признаки непонимания
Как минимум половине собравшихся.
Re: Признаки непонимания
Пока что ты никому не объяснил вообще.
Выглядит как "У нас есть ТАКИЕ приборы! Но мы вам о них не расскажем."
Re: Признаки непонимания
А все уже и так в курсе, объяснять-то нечего.
Re: Признаки непонимания
Пока что этому нет никаких подтверждений.
Re: Признаки непонимания
Подумай, почему ты не видишь никаких подтверждений.
Re: Признаки непонимания