Skip to content

Commit c4c6af8

Browse files
committed
Respond to comment
1 parent 544a282 commit c4c6af8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

_posts/2022-06-27-test-double-clocks.html

+22
Original file line numberDiff line numberDiff line change
@@ -437,4 +437,26 @@ <h2 id="comments-header">
437437
</div>
438438
<div class="comment-date">2024-05-08 11:13 UTC</div>
439439
</div>
440+
441+
<div class="comment" id="eddb383b90f8416aaecbee862b808df9">
442+
<div class="comment-author"><a href="/">Mark Seemann</a> <a href="#eddb383b90f8416aaecbee862b808df9">#</a></div>
443+
<div class="comment-content">
444+
<p>
445+
Thank you for writing. It's a good point that the two alternatives that I compare really only represent different perspectives. As one part becomes more explicit, the other becomes more implicit, and vice versa. I hadn't though of that, so thank you for pointing that out.
446+
</p>
447+
<p>
448+
Perhaps, as you suggest, a better API might be in order. I'm sure this isn't my last round around that block. I don't, however, want to add <code>Now</code>, <code>FutureDate</code>, etc. to the <code>Some</code> API. This module contains a collection of <a href="https://en.wikipedia.org/wiki/Equivalence_class">representative values of various equivalence classes</a>, and in order to ensure test repeatability, <a href="/2017/09/11/test-data-without-builders">they should be immutable</a> and deterministic. This rules out hiding a call to <code>DateTime.Now</code> behind such an API.
449+
</p>
450+
<p>
451+
That doesn't, however, rule out other types of APIs. If you move to <a href="/2017/09/18/the-test-data-generator-functor">test data generators</a> instead, it might make sense to define a 'future date' generator.
452+
</p>
453+
<p>
454+
All that said, I agree that the best way to test time-sensitive code is to model it in such a way that it's deterministic. I've <a href="/2020/02/24/discerning-and-maintaining-purity">touched on this topic before</a>, and most of the tests in the sample code base that accompanies <a href="/ctfiyh">Code That Fits in Your Head</a> takes that approach.
455+
</p>
456+
<p>
457+
The test discussed in this article, however, sits <a href="/2023/07/31/test-driving-the-pyramids-top">higher in the Test Pyramid</a>, and for such <a href="/2012/06/27/FacadeTest">Facade Tests</a>, I'd like to exercise them in as realistic a context as possible. That's why I run them on the real system clock.
458+
</p>
459+
</div>
460+
<div class="comment-date">2024-05-18 8:45 UTC</div>
461+
</div>
440462
</div>

0 commit comments

Comments
 (0)