<?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: Bharathwaaj S</title>
    <description>The latest articles on DEV Community by Bharathwaaj S (@bharathwaaj).</description>
    <link>https://dev.to/bharathwaaj</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%2F115051%2F3898031d-2fb5-479e-aa44-7bb8e0450307.png</url>
      <title>DEV Community: Bharathwaaj S</title>
      <link>https://dev.to/bharathwaaj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bharathwaaj"/>
    <language>en</language>
    <item>
      <title>Clean Code - How to write proper test case names</title>
      <dc:creator>Bharathwaaj S</dc:creator>
      <pubDate>Tue, 17 Mar 2020 21:47:55 +0000</pubDate>
      <link>https://dev.to/bharathwaaj/clean-code-how-to-write-proper-test-case-names-5ccf</link>
      <guid>https://dev.to/bharathwaaj/clean-code-how-to-write-proper-test-case-names-5ccf</guid>
      <description>&lt;p&gt;A test case consists of two parts&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Action&lt;/li&gt;
&lt;li&gt;Result&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Test cases should then be named accordingly. For an action, it should produce a result. The &lt;strong&gt;action word&lt;/strong&gt; should be modified as per the context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def test_action_produces_result
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above name, the &lt;strong&gt;produces&lt;/strong&gt; is the &lt;strong&gt;action word&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Check these names (Replace model with your specific table name)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def test_form_saves_title_field_in_model
def test_post_redirects_to_home_page
def test_recalculate_updates_score_field_in_model
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Corner cases can be tricky. You might be tempted to write otherwise. For ex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def test_score_field_is_present_in_excel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this case the action gets missed. However, the formula of action_produces_result can be always applied to provide more context&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def test_exported_excel_has_score_field
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are some cases where you aren't bothered about the result. These are usually in cases of regression. For ex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def test_users()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;However too many test cases of this type are mostly a result of laziness and should be cleaned up.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@jankolar?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Kolar.io&lt;/a&gt; on &lt;a href="https://unsplash.com/collections/8807452/flat-files?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cleancode</category>
      <category>testing</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
