<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[developer journey]]></title><description><![CDATA[I share my interests and insights. It's a place where I write about what I've learned and what excites me. 🚀💪]]></description><link>https://kittako.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1718398411013/-3puqBKOy.png</url><title>developer journey</title><link>https://kittako.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 01 Sep 2026 06:45:14 GMT</lastBuildDate><atom:link href="https://kittako.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Dive into Parameterized Tests: A Smarter Approach]]></title><description><![CDATA[When it comes to writing unit tests, we typically create a brand-new test method for each specific use case. Let me illustrate this with an example.
Example
Imagine a profile database, that can create a new profile for you.
final class ProfileDatabas...]]></description><link>https://kittako.hashnode.dev/dive-into-parameterized-tests-a-smarter-approach</link><guid isPermaLink="true">https://kittako.hashnode.dev/dive-into-parameterized-tests-a-smarter-approach</guid><category><![CDATA[Swift]]></category><category><![CDATA[unit testing]]></category><category><![CDATA[Testing]]></category><category><![CDATA[test driven development]]></category><category><![CDATA[automation testing ]]></category><dc:creator><![CDATA[Kithin Y.]]></dc:creator><pubDate>Mon, 11 Sep 2023 08:14:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/QszVePLear4/upload/6b4669b0e5a17075a5fe0478cdf6c337.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When it comes to writing unit tests, we typically create a brand-new test method for each specific use case. Let me illustrate this with an example.</p>
<h3 id="heading-example"><strong>Example</strong></h3>
<p>Imagine a profile database, that can create a new profile for you.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">final</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ProfileDatabase</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">create</span><span class="hljs-params">(<span class="hljs-number">_</span> profile: Profile)</span></span> -&gt; <span class="hljs-type">String</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-string">"🥳 profile has been created!"</span>
    }
}
</code></pre>
<p>When you're creating one, all that's required is providing the first name. Everything else? That's, completely optional.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Profile</span> </span>{
    <span class="hljs-keyword">let</span> firstName: <span class="hljs-type">String</span>
    <span class="hljs-keyword">let</span> lastName: <span class="hljs-type">String?</span>

    <span class="hljs-keyword">let</span> email: <span class="hljs-type">String?</span>
    <span class="hljs-keyword">let</span> phoneNumber: <span class="hljs-type">Int?</span>

    <span class="hljs-keyword">let</span> image: <span class="hljs-type">URL?</span>
}
</code></pre>
<p>To ensure our profile database works as intended, let's explore the various use cases, we have to cover with our tests.</p>
<ol>
<li><p>Just the first name.</p>
</li>
<li><p>First name and last name.</p>
</li>
<li><p>First name, last name, and email.</p>
</li>
<li><p>First name, last name, email, and phone number.</p>
</li>
<li><p>And finally, everything.</p>
</li>
</ol>
<h3 id="heading-common-way"><strong>Common way</strong></h3>
<p>For these five use cases, we create a brand-new test method for each one of them.</p>
<pre><code class="lang-swift"><span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">test_returnProfileHasBeenCreatedMessage_whenCreatingProfileWithOnlyFirstName</span><span class="hljs-params">()</span></span> <span class="hljs-keyword">throws</span> {
    <span class="hljs-keyword">let</span> profile = <span class="hljs-type">Profile</span>(
        firstName: <span class="hljs-string">"John"</span>,
        lastName: <span class="hljs-literal">nil</span>,
        email: <span class="hljs-literal">nil</span>,
        phoneNumber: <span class="hljs-literal">nil</span>,
        image: <span class="hljs-literal">nil</span>
    )

    <span class="hljs-keyword">let</span> message = sut.create(profile)

    <span class="hljs-type">XCTAssertEqual</span>(<span class="hljs-string">"🥳 profile has been created!"</span>, message)
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">test_returnProfileHasBeenCreatedMessage_whenCreatingProfileWithOnlyFirstNameAndLastName</span><span class="hljs-params">()</span></span> <span class="hljs-keyword">throws</span> {
    <span class="hljs-comment">// Test Code ...</span>
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">test_returnProfileHasBeenCreatedMessage_whenCreatingProfileWithOnlyFirstNameAndLastNameAndEmail</span><span class="hljs-params">()</span></span> <span class="hljs-keyword">throws</span> {
    <span class="hljs-comment">// Test Code ...</span>
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">test_returnProfileHasBeenCreatedMessage_whenCreatingProfileWithOnlyFirstNameAndLastNameAndEmailAndPhoneNumber</span><span class="hljs-params">()</span></span> <span class="hljs-keyword">throws</span> {
    <span class="hljs-comment">// Test Code ...</span>
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">test_returnProfileHasBeenCreatedMessage_whenCreatingProfileWithAllArguments</span><span class="hljs-params">()</span></span> <span class="hljs-keyword">throws</span> {
    <span class="hljs-comment">// Test Code ...</span>
}
</code></pre>
<p>As you take a closer look:</p>
<ul>
<li><p>For each use case, you'll need a brand-new test method.</p>
</li>
<li><p>Long method names can get confusing.</p>
</li>
<li><p>Code that repeats itself unnecessarily.</p>
</li>
</ul>
<h3 id="heading-a-better-solution-parameterized-tests"><strong>A better solution:</strong> Parameterized Tests</h3>
<p>Alright, let's dive into <code>Parameterized Tests</code>!</p>
<p>But first, what exactly is it?</p>
<p>Well, it's nothing more than writing a test that runs a piece of code repeatedly, but each time with a different input. This, in turn, leads to a different output.</p>
<p>In other words, you can cover multiple use cases within a single test.</p>
<p><strong>Step 1:</strong><br />To begin, we need to create a <code>generic struct</code> that can handle any type of input and output. So we can use it in any test with different input and output.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">TestCase</span>&lt;<span class="hljs-title">Input</span>, <span class="hljs-title">Output</span>&gt; </span>{
    <span class="hljs-keyword">let</span> input: <span class="hljs-type">Input</span>
    <span class="hljs-keyword">let</span> output: <span class="hljs-type">Output</span>

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">let</span> line: <span class="hljs-type">UInt</span>

    <span class="hljs-keyword">init</span>(
        input: <span class="hljs-type">Input</span>,
        output: <span class="hljs-type">Output</span>,
        line: <span class="hljs-type">UInt</span> = #line
    ) {
        <span class="hljs-keyword">self</span>.input = input
        <span class="hljs-keyword">self</span>.output = output
        <span class="hljs-keyword">self</span>.line = line
    }

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">message</span><span class="hljs-params">()</span></span> -&gt; <span class="hljs-type">String</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-string">"🚨 Failed on line: \(line)"</span>
    }
}
</code></pre>
<p><strong>Step 2:</strong><br />After creating the <code>generic struct</code>, we can use it.</p>
<p>Just create one test, and we're good to go!</p>
<pre><code class="lang-swift"><span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">test_returnProfileHasBeenCreatedMessage_whenCreatingProfile</span><span class="hljs-params">()</span></span> <span class="hljs-keyword">throws</span> {
    [
        <span class="hljs-type">TestCase</span>(
            input: <span class="hljs-type">Profile</span>(
                firstName: <span class="hljs-string">"John"</span>,
                lastName: <span class="hljs-literal">nil</span>,
                email: <span class="hljs-literal">nil</span>,
                phoneNumber: <span class="hljs-literal">nil</span>,
                image: <span class="hljs-literal">nil</span>
            ),
            output: <span class="hljs-string">"🥳 profile has been created!"</span>
        ),

        <span class="hljs-comment">// Remaining 4 Test Cases ...</span>

    ].forEach { testCase <span class="hljs-keyword">in</span>
        <span class="hljs-type">XCTAssertEqual</span>(
            testCase.output,
            sut.create(testCase.input),
            testCase.message()
        )
    }
}
</code></pre>
<h3 id="heading-benefits"><strong>Benefits</strong></h3>
<p>This has a few key benefits:</p>
<ol>
<li><p>Code Reusability: Write it once and use it with countless inputs - say goodbye to repetitive test code!</p>
</li>
<li><p>Readability: No more lengthy test method names. Everything's crystal clear and concise.</p>
</li>
<li><p>Input-Output Clarity: Clear input-output relationship.</p>
</li>
<li><p>Scalability: As your code grows, adding new use cases is a piece of cake. Keep that test suite up-to-date!</p>
</li>
</ol>
<h3 id="heading-food-for-thought"><strong>Food for thought</strong></h3>
<p>Did you find this article helpful? Go ahead and give that 🤍 like button a tap.<br />Your appreciation fuels my motivation to keep bringing you more content 💪.</p>
<p>If you have suggestions or improvements, feel free to share them in the comment section. Let's all learn new ways together!</p>
<h3 id="heading-resources"><strong>Resources</strong></h3>
<p>The example code in this article is right <a target="_blank" href="https://github.com/Kithin/parameterized-tests-example">here</a>, ready for you to delve into, learn from, and, ultimately, start applying in your own tests.</p>
<p>To get a firsthand look at how we've shifted from the Common Way to Parameterized Tests, explore the <a target="_blank" href="https://github.com/Kithin/parameterized-tests-example/commits/master">commits</a>.</p>
<h3 id="heading-references"><strong>References</strong></h3>
<p>Reid, J. (2021, February 28). Parameterized Swift Tests in XCTest (Live Coding). YouTube. <a target="_blank" href="https://www.youtube.com/watch?v=_RiEvcHl3_c">https://www.youtube.com/watch?v=_RiEvcHl3_c</a></p>
<p>Wake, B. (2020, November, 25). Parameterized Unit Testing. XP123. <a target="_blank" href="https://xp123.com/articles/parameterized-unit-testing/">https://xp123.com/articles/parameterized-unit-testing</a></p>
]]></content:encoded></item><item><title><![CDATA[Builder Pattern for creating Test Data]]></title><description><![CDATA[When writing automated tests, we use test data to test certain use cases.
Common way
One common way is creating test data via a constant.
let restaurantWithOnlyName = Restaurant( 
    name: "Delicioso food", 
    cuisines: nil, 
    rating: nil 
)

A...]]></description><link>https://kittako.hashnode.dev/builder-pattern-for-creating-test-data</link><guid isPermaLink="true">https://kittako.hashnode.dev/builder-pattern-for-creating-test-data</guid><category><![CDATA[builder pattern]]></category><category><![CDATA[Swift]]></category><category><![CDATA[unit testing]]></category><category><![CDATA[Testing]]></category><category><![CDATA[design patterns]]></category><dc:creator><![CDATA[Kithin Y.]]></dc:creator><pubDate>Wed, 23 Aug 2023 07:00:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/eteVOKwRuYc/upload/7532b2f7f0b3cc46dba88c310910b41f.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When writing automated tests, we use <code>test data</code> to test certain <code>use cases</code>.</p>
<h3 id="heading-common-way"><strong>Common way</strong></h3>
<p>One common way is creating test data via a <code>constant</code>.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> restaurantWithOnlyName = <span class="hljs-type">Restaurant</span>( 
    name: <span class="hljs-string">"Delicioso food"</span>, 
    cuisines: <span class="hljs-literal">nil</span>, 
    rating: <span class="hljs-literal">nil</span> 
)
</code></pre>
<p>And when you need to test a different use case. You need to create a new one.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> restaurantWithOnlyNameAndRating = <span class="hljs-type">Restaurant</span>(
     name: <span class="hljs-string">"Delicioso food"</span>,
     cuisines: <span class="hljs-literal">nil</span>,
     rating: <span class="hljs-number">5.0</span>
)
</code></pre>
<p>Soon you have many constants. Making it hard to maintain.<br />Imagine you need to:</p>
<ul>
<li><p>Change a property name</p>
</li>
<li><p>Add a new property</p>
</li>
<li><p>Delete a property</p>
</li>
</ul>
<p>You have to update not only one but all of them.</p>
<h3 id="heading-a-better-solution-the-builder-pattern"><strong>A better solution: The Builder pattern</strong></h3>
<p>There are better ways of creating test data. Among them is the <code>Builder pattern</code>. Creating objects step by step, using a <code>builder class</code>.</p>
<p><strong>Step 1:</strong><br />To start with, every property has a <code>default value</code>.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">RestaurantBuilder</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> name: <span class="hljs-type">String</span> = <span class="hljs-string">"Delicioso food"</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> cuisines: [<span class="hljs-type">String</span>]? = [<span class="hljs-string">"Seafood"</span>]
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> rating: <span class="hljs-type">Double?</span> = <span class="hljs-number">5.0</span>
}
</code></pre>
<p><strong>Step 2:</strong><br />Second, every property’s value is changeable via a <code>with(:)</code> method.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">RestaurantBuilder</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> name: <span class="hljs-type">String</span> = <span class="hljs-string">"Delicioso food"</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> cuisines: [<span class="hljs-type">String</span>]? = [<span class="hljs-string">"Seafood"</span>]
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> rating: <span class="hljs-type">Double?</span> = <span class="hljs-number">5.0</span>

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(name: String)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.name = name
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

     <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(cuisines: [String]?)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.cuisines = cuisines
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

     <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(rating: Double?)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.rating = rating
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }
}
</code></pre>
<p><strong>Step 3:</strong><br />And finally a <code>build(:)</code> method to construct the object using those values.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">RestaurantBuilder</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> name: <span class="hljs-type">String</span> = <span class="hljs-string">"Delicioso food"</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> cuisines: [<span class="hljs-type">String</span>]? = [<span class="hljs-string">"Seafood"</span>]
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> rating: <span class="hljs-type">Double?</span> = <span class="hljs-number">5.0</span>

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(name: String)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.name = name
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

     <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(cuisines: [String]?)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.cuisines = cuisines
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

     <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(rating: Double?)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.rating = rating
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">build</span><span class="hljs-params">()</span></span> -&gt; <span class="hljs-type">Restaurant</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-type">Restaurant</span>(
           name: <span class="hljs-keyword">self</span>.name,
           cuisines: <span class="hljs-keyword">self</span>.cuisines,
           rating: <span class="hljs-keyword">self</span>.rating
        )
    }
}
</code></pre>
<p><strong>Step 4:</strong><br />After creating the <code>builder class</code>, we can use it.</p>
<p>When we are testing a use case, where the exact values of the properties don't matter, we can use the default values.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> restaurant = <span class="hljs-type">RestaurantBuilder</span>().build()
</code></pre>
<p>And when we are testing a use case, where the exact values of the properties matter, we can change the default values.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> restaurant = <span class="hljs-type">RestaurantBuilder</span>()
    .with(name: <span class="hljs-string">"Awesome Delicioso food"</span>)
    .build()
</code></pre>
<h3 id="heading-benefits"><strong>Benefits</strong></h3>
<ul>
<li><p>Creating test data is made simple: It's fast and easy.</p>
</li>
<li><p>Keeping things maintainable: If the model changes, we only have to update the builder class. All the configuration takes place there.</p>
</li>
<li><p>Highlighting only what matters: You only change the values of the properties that matter. Removing all distractions.</p>
</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-comment">// Create Restaurant with 5.0 star rating</span>
<span class="hljs-keyword">let</span> restaurantWithFiveStarRating = <span class="hljs-type">Restaurant</span>(
     name: <span class="hljs-string">"Delicioso food"</span>,
     cuisines: <span class="hljs-literal">nil</span>,
     rating: <span class="hljs-number">5.0</span>
)

<span class="hljs-keyword">let</span> restaurant = <span class="hljs-type">RestaurantBuilder</span>()
    .with(rating: <span class="hljs-number">5.0</span>)
    .build()
</code></pre>
<h3 id="heading-complex-data"><strong>Complex data</strong></h3>
<p>Data can be(come) complex. Imagine we want to provide the location of a <code>Restaurant</code>.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Location</span> </span>{
    <span class="hljs-keyword">let</span> address: <span class="hljs-type">String?</span>
    <span class="hljs-keyword">let</span> zipCode: <span class="hljs-type">Int?</span>
    <span class="hljs-keyword">let</span> city: <span class="hljs-type">String?</span>
    <span class="hljs-keyword">let</span> country: <span class="hljs-type">String?</span>
}

<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Restaurant</span> </span>{
    <span class="hljs-keyword">let</span> name: <span class="hljs-type">String</span>
    <span class="hljs-keyword">let</span> cuisines: [<span class="hljs-type">String</span>]?
    <span class="hljs-keyword">let</span> rating: <span class="hljs-type">Int</span>
    <span class="hljs-keyword">let</span> location: <span class="hljs-type">Location?</span>
}
</code></pre>
<p>We have to update our <code>RestaurantBuilder</code> to conform to this new change. To make this happen, we need to create a new builder class, <code>LocationBuilder</code> for the model <code>Location</code>. Then we will use this for setting the default value for the <code>location</code> property.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">RestaurantBuilder</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> name: <span class="hljs-type">String</span> = <span class="hljs-string">"Delicioso food"</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> cuisines: [<span class="hljs-type">String</span>]? = [<span class="hljs-string">"Seafood"</span>]
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> rating: <span class="hljs-type">Double?</span> = <span class="hljs-number">5.0</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> location: <span class="hljs-type">Location?</span> = <span class="hljs-type">LocationBuilder</span>().build()

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(name: String)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.name = name
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

     <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(cuisines: [String]?)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.cuisines = cuisines
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

     <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(rating: Double?)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.rating = rating
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

   <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">with</span><span class="hljs-params">(location: Location?)</span></span> -&gt; <span class="hljs-type">Self</span> {
        <span class="hljs-keyword">self</span>.location = location
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>
    }

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">build</span><span class="hljs-params">()</span></span> -&gt; <span class="hljs-type">Restaurant</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-type">Restaurant</span>(
           name: <span class="hljs-keyword">self</span>.name,
           cuisines: <span class="hljs-keyword">self</span>.cuisines,
           rating: <span class="hljs-keyword">self</span>.rating,
           location: <span class="hljs-keyword">self</span>.location
        )
    }
}
</code></pre>
<h3 id="heading-food-for-thought"><strong>Food for thought</strong></h3>
<p>Did you find this article helpful? Go ahead and give that 🤍 like button a tap.<br />Your appreciation fuels my motivation to keep bringing you more content 💪.</p>
<p>If you do have other ways of creating test data, feel free to share them in the comment section. Let's all learn new ways together!</p>
<h3 id="heading-references"><strong>References</strong></h3>
<p>Steve Freeman, S., &amp; Nat Pryce, N., 2009. <em>Growing Object-Oriented Software, Guided by Tests</em></p>
]]></content:encoded></item></channel></rss>