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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>1st item is not possible in elixir, since you can’t call function with wrong parameters (it won’t compile). By “wrong” I mean too much/too little params.</p>
<p>This leaves us to 2nd item - making sure you handle data correctly. That’s why you mock data, not services.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108019" 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/good-elixir-tdd-resources/17482/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-108019" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108019"
                     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 #21"></div>
  </section>
</div>
    <div class="postbit" id="108022" data-post-id="108022">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="StefanHoutzager" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  StefanHoutzager
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Btw:<br>
I googled “integration tests are a scam” because that title seemed strange. The title appeared a mistake: <a href="https://blog.thecodewhisperer.com/permalink/clearing-up-the-integrated-tests-scam" class="inline-onebox" rel="noopener nofollow ugc">Clearing Up the Integrated Tests Scam - The Code Whisperer</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="108022" 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/good-elixir-tdd-resources/17482/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-108022" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108022"
                     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 #22"></div>
  </section>
</div>
    <div class="postbit" id="108023" data-post-id="108023">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Fl4m3Ph03n1x" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Fl4m3Ph03n1x/120/11709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Fl4m3Ph03n1x
                    <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="Egis" data-post="22" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/egis/48/6376_2.png" class="avatar"> Egis:</div>
<blockquote>
<p>1st item is not possible in elixir, since you can’t call function with wrong parameters (it won’t compile). By “wrong” I mean too much/too little params.</p>
</blockquote>
</aside>
<p>I am not talking about a signature ( you even have spec to help with that ) I am talking about calling the contract with params that make no sense. Like wrong values and such.</p>
<p>Really, go watch the video conference. It will help you understand the context of this discussion:</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=VDfX44fZoMc" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=VDfX44fZoMc</a></li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108023" 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/good-elixir-tdd-resources/17482/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-108023" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108023"
                     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 #23"></div>
  </section>
</div>
    <div class="postbit" id="108024" data-post-id="108024">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="24" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>I am talking about calling the contract with params that make no sense. Like wrong values and such.</p>
</blockquote>
</aside>
<p>Property testing to the rescue! <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Edit: also dialyzer.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108024" 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/good-elixir-tdd-resources/17482/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-108024" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108024"
                     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 #24"></div>
  </section>
</div>
    <div class="postbit" id="108026" data-post-id="108026">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Fl4m3Ph03n1x" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Fl4m3Ph03n1x/120/11709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Fl4m3Ph03n1x
                    <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">
								<p><a class="mention" href="/u/egis" rel="nofollow">@Egis</a> Dialyzer won’t save you. In fact, if you are using Elixir 1.7.X it will even hurt you, as it doesn’t even work.<br>
Even if ti did work, it wouldn’t matter. Dialyzer can’t understand that a method being called with “foo” should be instead called with “baz”. For Dialyzer, both are strings and the function’s signature is correct, so it passes.</p>
<p>As for property testing, I am not convinced. I am actually reading a book that mentions it ( The Little Elixir and OTP Guidebook ) but the examples are rather contrived and perfected to make sense using property testing. The applications to the real world are … considerably more limited.</p>
<p>Still, this is a discussion for another topic. I don’t think property testing is a good as people say ( feel free to create a new discussion referring me if you want to try and convince me) but I am still studying it’s potential applications.</p>
<p>This discussion is about TDD and good resources for those who value 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="108026" 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/good-elixir-tdd-resources/17482/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-108026" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108026"
                     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 #25"></div>
  </section>
</div>
    <div class="postbit" id="108027" data-post-id="108027">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="26" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>In fact, if you are using Elixir 1.7.X it will even hurt you, as it doesn’t even work.</p>
</blockquote>
</aside>
<p>Please do not tell it like this, as dialyzer works with 1.7.x if the OTP versions match. This is not an issue of dialyzer or elixir, this is an issue of installing the correct things in the correct versions.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="26" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>For Dialyzer, both are strings and the function’s signature is correct, so it passes.</p>
</blockquote>
</aside>
<p>This sounds to me as if the types haven’t specified correctly.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="26" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>As for property testing, I am not convinced.</p>
</blockquote>
</aside>
<p>Sad. You should give it a go. For algorithms that have well defined properties this is a nice thing.</p>
<p>Eg. <code>list == list |&gt; reverse |&gt; reverse</code> or <code>a + b == b + a</code> or <code>len(a++b) == len(a) + len(b)</code>. Having those is really nice. Of course it requires a different set of thinking than example based testing.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108027" 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/good-elixir-tdd-resources/17482/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-108027" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108027"
                     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 #26"></div>
  </section>
</div>
    <div class="postbit" id="108035" data-post-id="108035">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Fl4m3Ph03n1x" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Fl4m3Ph03n1x/120/11709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Fl4m3Ph03n1x
                    <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="NobbZ" data-post="27" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>Please do not tell it like this, as dialyzer works with 1.7.x if the OTP versions match.</p>
</blockquote>
</aside>
<p>No it doesn’t: <a href="https://stackoverflow.com/questions/53427886/which-version-of-elixir-otp-erlang-can-we-use-with-dialyzer" rel="noopener nofollow ugc">https://stackoverflow.com/questions/53427886/which-version-of-elixir-otp-erlang-can-we-use-with-dialyzer</a></p>
<aside class="quote no-group" data-username="NobbZ" data-post="27" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>This sounds to me as if the types haven’t specified correctly.</p>
</blockquote>
</aside>
<p>Dialyzer checks types. Doesn’t check values. I could have a function <code>add</code> return <code>1+1=3</code>  and it would pass. Why? both are numbers, return a number and the function takes the correct number of parameters. It is still wrong. Dialyzer doesn’t know any better because it doesn’t check values. That’s the job of TDD. To say that Dialyzer can replace TDD is just flat out wrong. It can help, sure, but never replace.</p>
<aside class="quote no-group" data-username="NobbZ" data-post="27" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>Sad. You should give it a go. For algorithms that have well defined properties this is a nice thing.</p>
</blockquote>
</aside>
<p>Yo are correct. However I found two main issues:</p>
<ol>
<li>Few times we have code that deals with nice algorithms that deal with very well defined properties. Sure, if you want to re-invent the wheel and reverse lists it will work fine but real life apps are messy and full of side effects and edge cases that don’t quite fit into PT.</li>
<li>The code you write with PT is actually … quite complex. I am not even talking about recursive generators nor trees, but even the most simple things, like applying the reverse algorithm, require you to code both the solution <em>and</em> the counter solution. If I don’t know my solution works well, how am I supposed to know my counter-solution used to test my solution does? It makes no sense to me ( PS: counter solution = inverse function, inverse algorithm, equivalent of the undo operation ).</li>
</ol>
<p>I am not giving up on PT, not yet. I want to delve deeper into it, however at this point in time, I am still not convinced <img src="https://forum.elixirforum.com/images/emoji/apple/stuck_out_tongue.png?v=15" title=":stuck_out_tongue:" class="emoji" alt=":stuck_out_tongue:" loading="lazy" width="20" height="20"></p>
<p>But power to you if you make it work for you. Perhaps you have some resources I could use?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108035" 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/good-elixir-tdd-resources/17482/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-108035" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108035"
                     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 #27"></div>
  </section>
</div>
    <div class="postbit" id="108045" data-post-id="108045">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="28" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>I am not even talking about recursive generators nor trees, but even the most simple things, like applying the reverse algorithm, require you to code both the solution <em>and</em> the counter solution.</p>
</blockquote>
</aside>
<p>The counter should generally be part of the API as well for simple property tests.  However property tests are not just about reverse testing but about invariant testing, like have it generate inputs into a state system, test that the state of it is valid each time and make sure it ends at a proper place given the inputs, even without knowing the values you catch a <em>significant</em> amount of bugs.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="28" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>But power to you if you make it work for you. Perhaps you have some resources I could use?</p>
</blockquote>
</aside>
<p>As a good example of state testing see the Elevator example for the C side of the QuickCheck library (which uses Erlang to do the testing) for how to think about it.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108045" 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/good-elixir-tdd-resources/17482/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-108045" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108045"
                     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 #28"></div>
  </section>
</div>
    <div class="postbit" id="108051" data-post-id="108051">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Aspect: Testing as One Driver of Design</p>
<aside class="quote no-group" data-username="NobbZ" data-post="27" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>For algorithms that have well defined properties this is a nice thing.</p>
</blockquote>
</aside>
<p>My exposure to property testing is minimal (e.g. worked through an elaborate a QuickCheck demonstration in Haskell) and for the time being <a href="https://forum.elixirforum.com/t/property-based-testing-with-proper-erlang-and-elixir-pragprog/15339" rel="nofollow">Elixir Forum Property-Based Testing with PropEr, Erlang, and Elixir</a> is a bit of a specialist topic for me to fully commit - but the reason it is staying on my radar is that I suspect that beyond the primary benefits it may impose beneficial design pressures on the code.</p>
<blockquote>
<p>you find a rule that dictates the behavior that should always be the same no matter what sample input you give to your program, and encode that into some executable code—a property.</p>
</blockquote>
<ol>
<li>
<p>In order to use property based testing the STU has to be designed against somewhat coherent (and explicitly stated) rules that the tests can be based on (now if the same was only true for “business” logic). So if you want to leverage property based testing it seems the need for “rules” improves coherence. The flip side is that if you can’t be bothered to discover/refine those “rules”, you are not going to see the value in property based testing. With example based testing there is never any real incentive to unify fragmented, incoherent logic.</p>
</li>
<li>
<p>While this <a href="https://hypothesis.works/articles/referential-transparency/" rel="noopener nofollow ugc">rant</a> states that “You Don’t <strong>Need</strong> Referential Transparency” I’d be inclined to believe that property based testing would drive you towards <em>preferring</em> referential transparency.</p>
</li>
</ol>
<p>However I still see property based testing as a rather specialized tool in the “testing” part of software development, likely useful for <a href="https://youtu.be/H3LOyuqhaJA" rel="noopener nofollow ugc">micro tests</a>, possibly useful with collaboration tests, likely not appropriate for <a href="https://martinfowler.com/bliki/ContractTest.html" rel="noopener nofollow ugc">contract tests</a>.</p>
<p>Some approaches to testing can be inefficient/ineffective (similar to the situation in process and documentation). Hypothetically property based testing should be more efficient than example based testing because it can cover more values with less effort. But the issue is that it can’t <em>replace</em> example based testing.</p>
<p>Given that developers will be exposed to example based testing first (and testing is a means to an end, rather than an end in itself - unless you are <em>specializing</em> in testing) they may never get exposed to property based testing.</p>
<p>Then there is the possibility that property based testing is only applicable and effective for code bases that already meet certain quality standards.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="26" data-topic="17482">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>the examples are rather contrived and perfected to make sense using property testing</p>
</blockquote>
</aside>
<p>Which begs the question: could some software benefit from being “perfected” (i.e. designed) to be more amenable to property based testing and would that improve the software’s design from functional and maintenance perspective?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108051" 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/good-elixir-tdd-resources/17482/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-108051" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108051"
                     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 #29"></div>
  </section>
</div>
    <div class="postbit" id="108057" data-post-id="108057">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Chiming in, as I am also a big fan of TDD but not fanatical in my implementation of it.</p>
<p>I have experienced the same thing  <a class="mention" href="/u/fl4m3ph03n1x" rel="nofollow">@Fl4m3Ph03n1x</a> , testing in Elixir is requires a lot of arcane knowledge that will not arise from getting into the code and writing the tests. Elixir lacks a popular opinionated testing framework and it is easy to do wrong, or to architect your code base to make testing a slog.</p>
<p>I’m working on a blog post about this exact subject, so I will share some of my notes.</p>
<h1><a name="p-108057-macros-make-the-dream-work-1" class="anchor" href="#p-108057-macros-make-the-dream-work-1" aria-label="Heading link" rel="nofollow"></a>Macros make the dream work</h1>
<p>Keep in mind: Macros make the dream work! They let you write amazing abstractions for your code and I highly recommend getting VERY familiar.</p>
<p>There is a book by THE Chris McCord <a href="https://pragprog.com/book/cmelixir/metaprogramming-elixir" class="inline-onebox" rel="noopener nofollow ugc">Search</a></p>
<h1><a name="p-108057-the-new-facade-pattern-2" class="anchor" href="#p-108057-the-new-facade-pattern-2" aria-label="Heading link" rel="nofollow"></a>The (new) Facade Pattern</h1>
<p>First and foremost, there is a pattern we have yet to name but is mentioned over and over in the community to enable clean mocking and testing. You can find resources on it here:</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=Ue--hvFzr0o&amp;list=PLqj39LCvnOWaxI87jVkxSdtjG8tlhl7U6&amp;index=8" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=Ue--hvFzr0o&amp;list=PLqj39LCvnOWaxI87jVkxSdtjG8tlhl7U6&amp;index=8</a></li>
<li><a href="http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/" class="inline-onebox" rel="noopener nofollow ugc">Mocks and explicit contracts « Plataformatec Blog</a></li>
<li>Use Mox for mocking: <a href="https://github.com/plataformatec/mox" class="inline-onebox" rel="noopener nofollow ugc">GitHub - dashbitco/mox: Mocks and explicit contracts in Elixir · GitHub</a></li>
</ul>
<h1><a name="p-108057-mocking-using-a-fake-server-process-3" class="anchor" href="#p-108057-mocking-using-a-fake-server-process-3" aria-label="Heading link" rel="nofollow"></a>Mocking using  a fake server process</h1>
<p>a good reference impl of this is bamboo.</p>
<ul>
<li><a href="https://github.com/thoughtbot/bamboo/blob/master/lib/bamboo/test.ex" class="inline-onebox" rel="noopener nofollow ugc">bamboo/lib/bamboo/test.ex at master · beam-community/bamboo · GitHub</a></li>
<li><a href="https://github.com/thoughtbot/bamboo/blob/master/test/lib/bamboo/adapters/mandrill_adapter_test.exs" class="inline-onebox" rel="noopener nofollow ugc">bamboo/test/lib/bamboo/adapters/mandrill_adapter_test.exs at master · beam-community/bamboo · GitHub</a></li>
</ul>
<h1><a name="p-108057-other-resources-4" class="anchor" href="#p-108057-other-resources-4" aria-label="Heading link" rel="nofollow"></a>Other resources</h1>
<p>Additionally, I do property based checking and macro away as much boilerplate as I can.</p>
<ul>
<li>read this book: <a href="https://pragprog.com/book/fhproper/property-based-testing-with-proper-erlang-and-elixir" class="inline-onebox" rel="noopener nofollow ugc">Search</a> and use propcheck for a lot of my testing.</li>
<li>There are a lot of good libraries here, look through them and see if any of them speak to you. Don’t be shy about forking and taking over maintenance of a project that has died and looks promising! I like your opinions and I think writing an opinionated framework would be great! <a href="https://github.com/h4cc/awesome-elixir#testing" class="inline-onebox" rel="noopener nofollow ugc">GitHub - h4cc/awesome-elixir: A curated list of amazingly awesome Elixir and Erlang libraries, resources and shiny things. Updates: · GitHub</a></li>
<li><a href="https://github.com/thoughtbot/ex_machina" class="inline-onebox" rel="noopener nofollow ugc">GitHub - beam-community/ex_machina: Create test data for Elixir applications · GitHub</a> for generating test data</li>
<li>Meck is controversial, but you can just decide to use it anyway: <a href="https://github.com/eproxus/meck" class="inline-onebox" rel="noopener nofollow ugc">GitHub - eproxus/meck: A mocking library for Erlang · GitHub</a></li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="108057" 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/good-elixir-tdd-resources/17482/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-108057" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="108057"
                     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 #30"></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/17482/load_more?page=4">Load more posts (5 remaining)</a>
</div></template></turbo-stream>