<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="295287" data-post-id="295287">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SeanShubin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/SeanShubin/120/30038_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SeanShubin
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="al2o3cr" data-post="3" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/48/3457_2.png" class="avatar"> al2o3cr:</div>
<blockquote>
<p>I can see how it could be extended, but I can also see how it could get out of hand as “bigger” functions end up having to shuffle around a bunch of arguments as their dependencies need different things.</p>
</blockquote>
</aside>
<p>That is why I use a factory function, I expect I will be able to create other factory functions or parameterize existing factory functions to consolidate that kind of complexity as necessary.</p>
<aside class="quote no-group" data-username="al2o3cr" data-post="3" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/48/3457_2.png" class="avatar"> al2o3cr:</div>
<blockquote>
<p>One major challenge with this style: there’s no way for the compiler to verify calls like <code>io.puts(line)</code> have the right arity (or even refer to a function that <em>exists</em>) so you’re converting a lot of compile-time errors into runtime ones.</p>
</blockquote>
</aside>
<p>That certainly is a tradeoff to balance against.  Thanks for pointing it out.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295287" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-295287" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295287"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="295288" data-post-id="295288">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="SeanShubin" data-post="11" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/seanshubin/48/30038_2.png" class="avatar"> SeanShubin:</div>
<blockquote>
<p>I still have a problem because the test implementations are going to clobber each other’s state if run concurrently.</p>
</blockquote>
</aside>
<p>No they aren’t. You keep saying this, and we keep trying to tell you that this isn’t how Mox works. Please watch the linked video, or read through the Mox docs. It’s literally bullet point 3 of <a href="https://hexdocs.pm/mox/Mox.html" class="inline-onebox" rel="nofollow">Mox — Mox v1.2.0</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295288" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-295288" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295288"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="295289" data-post-id="295289">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SeanShubin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/SeanShubin/120/30038_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SeanShubin
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sodapopcan" data-post="6" data-topic="57135" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/48/34668_2.png" class="avatar"> sodapopcan:</div>
<blockquote>
<p>The only “global state” it relies on is which implementation of a module to load. Modules themselves have no state so it has no effect on concurrent tests.</p>
</blockquote>
</aside>
<p>The state I am worried about is things like recording side effects in IO.puts, or specifying external behavior in things like System.monotonic_time.  So far this is the simplest solution I have been able to come up with to test these kinds of interactions.  If I have one nondeterministic module that two other modules depend on, I don’t know how to get that nondeterminism under test coverage except by creating state to keep track of what is going on, and I don’t know how keep that state from getting clobbered during an async test without dynamically generating a namespace within which to store that state.  Using dynamically named modules solved the issue of state collision, while at the same time minimizing my need to change the production code because the fake module appears to be no different from the real one from the perspective of the code that depends on it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295289" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-295289" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295289"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="295291" data-post-id="295291">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I think you’re missing some fundamentals of how the BEAM works:</p>
<aside class="quote no-group" data-username="SeanShubin" data-post="14" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/seanshubin/48/30038_2.png" class="avatar"> SeanShubin:</div>
<blockquote>
<p>dynamically generating a namespace within which to store that state</p>
</blockquote>
</aside>
<p>State is not stored in namespaces either, it is stored in processes.  Though it’s also not clear what you mean by namespace.</p>
<p>Perhaps I’m not the best person to give an eloquent answer here, but if you’re talking about the pattern of naming a GenServer after a module, it is merely a convention and is simply just a name that happens to match the module’s name—it has nothing to do with the module itself.  You can call a GenServer whatever you like.  If you really want to track state during tests runs then you should could could start an Agent or something for each suite.  But again, state is stored in processes, not modules.  Each test file runs in its own processes.  They can’t touch each others’ state.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295291" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-295291" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295291"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="295292" data-post-id="295292">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SeanShubin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/SeanShubin/120/30038_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SeanShubin
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ityonemo" data-post="7" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ityonemo/48/11341_2.png" class="avatar"> ityonemo:</div>
<blockquote>
<p>If you are wondering about the mechanics of how concurrency works with mox</p>
</blockquote>
</aside>
<p>I did not know there were process dictionaries that were isolated from each other, I thought my only choice was to use a dynamically generated global name.  However, even with a process dictionary, as far as I can tell, I still need state to test nondeterminism, which means I need a process to manage that state, which means I still need a dynamically generated name.  Mox appears to help me create a production and test version of a module, but what I think I need is a production version and multiple test versions with their own state.</p>
<p>The video was interesting, as are process dictionaries, thanks for drawing my attention to it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295292" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-295292" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295292"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="295293" data-post-id="295293">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SeanShubin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/SeanShubin/120/30038_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SeanShubin
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="benwilson512" data-post="8" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/48/1457_2.png" class="avatar"> benwilson512:</div>
<blockquote>
<p>The weirdness in your case is passing in all of the dependencies as arguments, which intrudes into not only ever function in that module, but also every function that calls those functions.</p>
</blockquote>
</aside>
<p>That is a good argument to specify the production implementations as defaults, that way there is no intrusion into calling modules.  I had taken them out of the example for simplicity’s sake, but your observation certainly justifies putting the defaults back in.  As for the intrusion into functions within the module itself, yes it is more verbose, but it also makes it more obvious where nondeterminism is going on, so I suspect this will actually make it easier to reason about where to place abstraction boundaries.</p>
<aside class="quote no-group" data-username="benwilson512" data-post="8" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/48/1457_2.png" class="avatar"> benwilson512:</div>
<blockquote>
<p>In Mox, the immediate caller of the behavior has to do a lookup of the which behavior is currently in place, but callers thereof are not affected. The “global” bit is simply which behavior implementation is configured. As <a class="mention" href="/u/ityonemo" rel="nofollow">@ityonemo</a> notes, the specific functions are test specific, they are not global at all.</p>
</blockquote>
</aside>
<p>Using defaults also makes the callers not affected for in the tests, and the tests are necessarily affected as they have to manage the state to keep track of the nondeterminism.  It is not the modules or functions that make this troublesome, it is the need to maintain state to keep track of the nondeterminism.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295293" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-295293" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295293"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="295294" data-post-id="295294">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="SeanShubin" data-post="16" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/seanshubin/48/30038_2.png" class="avatar"> SeanShubin:</div>
<blockquote>
<p>but what I think I need is a production version and multiple test versions with their own state.</p>
</blockquote>
</aside>
<p>You are conflating functions and state. When you set up <code>Mox |&gt; expect</code> in a test you are attaching functions that will be called for the test in question, as distinct from any other tests. There is no state <em>at all</em> in that. If you want to <em>add</em> state you can choose to do so by say, spawning a genserver for each test, and then calling out to that genserver within the <code>|&gt; expect</code>ed functions for each test. This would be 100% deterministic and isolated for every test.</p>
<p>I may have time later and I’ll sketch up an example of what this looks like for IO and time. You’re still approaching this from an OO world where the functions and state are bound.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295294" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-295294" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295294"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="295296" data-post-id="295296">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SeanShubin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/SeanShubin/120/30038_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SeanShubin
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="tfwright" data-post="9" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>Not to pile on</p>
</blockquote>
</aside>
<p>Pile on all you like, the feedback is really helping me understand and articulate the problem I am trying to solve better.</p>
<aside class="quote no-group" data-username="tfwright" data-post="9" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>as someone who is also passionate about not allowing test specific concerns to leak into the architecture of an app</p>
</blockquote>
</aside>
<p>I share your passion, with the caveat that this does not apply to tests that are helping you detect that you have drawn an abstraction boundary incorrectly.</p>
<aside class="quote no-group" data-username="tfwright" data-post="9" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>this seems like the crux of the issue</p>
</blockquote>
</aside>
<p>I suspect we agree, but I want to be more precise by saying I think the crux of the issue is making sure the tests are empowering us to identify and isolate sensible abstraction boundaries, and that deterministic vs nondeterministic code is the most important of all such boundaries.</p>
<aside class="quote no-group" data-username="tfwright" data-post="9" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>introducing the requirement that each implementation needs to be passed in the arguments seems like a step backward</p>
</blockquote>
</aside>
<p>Not each implementation, but certainly each implementation containing nondeterminism.  I am not so sure it is a step backwards to be more explicit about where the nondeterminism lies, especially if you value “functional” programming.</p>
<aside class="quote no-group" data-username="tfwright" data-post="9" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>The application environment seems like the natural place to store information about which modules the application should use in the current environment</p>
</blockquote>
</aside>
<p>That would be true if I didn’t have to contend with different tests needing different state, and if I had one implementation for prod and a separate implementation for test, but it is my impression that because of state I actually need multiple test implementations.</p>
<aside class="quote no-group" data-username="tfwright" data-post="9" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>especially since one of the challenges in writing elixir is already the need to pass around lots of references in arguments.</p>
</blockquote>
</aside>
<p>You would never have to pass in a reference to something that only contained pure functions.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295296" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-295296" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295296"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="295297" data-post-id="295297">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SeanShubin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/SeanShubin/120/30038_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SeanShubin
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="D4no0" data-post="10" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/d4no0/48/33624_2.png" class="avatar"> D4no0:</div>
<blockquote>
<p>It is true, the approach of injecting every dependency as argument is bad practice here,</p>
</blockquote>
</aside>
<p>Not every dependency, just every dependency that contains nondeterminism.  I am not so sure it is bad practice to be explicit about where the nondeterminism lies, especially if you want to encourage “functional” style for most of the code.  Being more explicit about nondeterminism can actually make it easier to reason about where to draw abstraction boundaries.  I would hope to isolate the nondeterminism and modules that depend on it as much as possible, leaving the vast majority of the code base pure functional.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295297" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-295297" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295297"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="295298" data-post-id="295298">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SeanShubin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/SeanShubin/120/30038_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SeanShubin
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="benwilson512" data-post="13" data-topic="57135">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/48/1457_2.png" class="avatar"> benwilson512:</div>
<blockquote>
<p>No they aren’t. You keep saying this, and we keep trying to tell you that this isn’t how Mox works. Please watch the linked video, or read through the Mox docs. It’s literally bullet point 3 of <a href="https://hexdocs.pm/mox/Mox.html" rel="noopener nofollow ugc">Mox — Mox v1.0.2</a></p>
</blockquote>
</aside>
<p>Hmm, so perhaps Mox is somehow using the process dictionary to keep expectations isolated?  I am not trying to be dense, perhaps I am just getting tripped up on the wording.  I keep hearing how Mox allows for separate implementations when I am worried about separate state.  Over the weekend I should have time to create a prototype using Mox, so hopefully I will either address my own concerns or be able to articulate them more precisely.</p>
<p>I intend to get this example under 100% test coverage</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Hello do
  def main(args) do
      time_unit = :microsecond
      microseconds_before = System.monotonic_time time_unit
      target = args |&gt; List.first |&gt; File.read!
      IO.puts "Hello, #{target}!"
      microseconds_after = System.monotonic_time time_unit
      microseconds_duration = microseconds_after - microseconds_before
      IO.puts "Took #{microseconds_duration} microseconds"
  end
end
</code></pre>
<p>Also, I don’t mean to be repetitive, I was addressing each reply in order.  I do appreciate you all taking the time to help me understand.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295298" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-better-way-to-test-elixir/57135/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-295298" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295298"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/57135/load_more?page=3">Load more posts (12 remaining)</a>
</div></template></turbo-stream>