<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: lbabich</title>
    <description>The latest articles on DEV Community by lbabich (@lbabich).</description>
    <link>https://dev.to/lbabich</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F125462%2F8f069104-3399-412f-a4cb-bf42400428aa.jpeg</url>
      <title>DEV Community: lbabich</title>
      <link>https://dev.to/lbabich</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lbabich"/>
    <language>en</language>
    <item>
      <title>The ColdBrew - Introduction</title>
      <dc:creator>lbabich</dc:creator>
      <pubDate>Tue, 12 May 2020 10:14:55 +0000</pubDate>
      <link>https://dev.to/lbabich/the-coldbrew-introduction-4nj6</link>
      <guid>https://dev.to/lbabich/the-coldbrew-introduction-4nj6</guid>
      <description>&lt;p&gt;Hey all! Little bit of a shameless self promo here. Decided to take a little self plunge and work on youtube channel for tech related content! So this is just a small little intro into what it's about.&lt;/p&gt;

&lt;p&gt;Here you go: &lt;a href="https://youtu.be/z3WttAlrvNk"&gt;https://youtu.be/z3WttAlrvNk&lt;/a&gt;&lt;/p&gt;

</description>
      <category>code</category>
    </item>
    <item>
      <title>Unit Testing Mock Dependency Calls</title>
      <dc:creator>lbabich</dc:creator>
      <pubDate>Thu, 27 Jun 2019 12:03:04 +0000</pubDate>
      <link>https://dev.to/lbabich/unit-testing-mock-dependency-calls-443p</link>
      <guid>https://dev.to/lbabich/unit-testing-mock-dependency-calls-443p</guid>
      <description>&lt;p&gt;So me and a colleague are busy going through the unit testing motions. Let me set up 2 scenario's:&lt;/p&gt;

&lt;h1&gt;
  
  
  Scenario 1
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;There are two services. &lt;em&gt;Service one&lt;/em&gt; has a dependency on &lt;em&gt;service two&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;A method call in &lt;em&gt;service one&lt;/em&gt; returns a value but also calls a method from &lt;em&gt;service two&lt;/em&gt;, while passing values to that method (&lt;em&gt;Service two&lt;/em&gt; does not return any value).&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Scenario 2
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;There are two services. &lt;em&gt;Service one&lt;/em&gt; has a dependency on &lt;em&gt;service two&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;A method call in &lt;em&gt;service one&lt;/em&gt; returns a value but also calls a method from &lt;em&gt;service two&lt;/em&gt;, while passing values to that method.&lt;/li&gt;
&lt;li&gt;Service two method has a return value that directly affects the return result of &lt;em&gt;service one&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Testing Scenarios
&lt;/h1&gt;

&lt;p&gt;With &lt;strong&gt;scenario one&lt;/strong&gt; I would argue that you would first stub the &lt;em&gt;service two&lt;/em&gt; dependency. Then ensure that the value passed to that stub are what you would expect. The reason being you are ensuring that the outside dependency is passed what you expect and called, as you should have no direct knowledge of what it does with it.&lt;/p&gt;

&lt;p&gt;However with &lt;strong&gt;scenario 2&lt;/strong&gt;, my argument is you would stub &lt;em&gt;service two&lt;/em&gt; dependency. However you would have no need to make sure that the method was called or what it was called with. You would however make sure it was called if it was down a certain branch of logic. However since you are directly determining the return value of the &lt;em&gt;service two&lt;/em&gt; method you are testing your scenarios specific to that unit test. If you wanted to know what was being passed into that method and result then you are either looking at the need to refactor your code or you are needing to make a unit test and integration test scenario.&lt;/p&gt;

&lt;p&gt;I would just like to get peoples opinions on this and how they approach it.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>javascript</category>
      <category>unittest</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
