<?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: Alan Liew</title>
    <description>The latest articles on DEV Community by Alan Liew (@alan_liew_888888888).</description>
    <link>https://dev.to/alan_liew_888888888</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%2F1782136%2F487f1c11-f948-4c9e-bc0a-87d21a3f56c4.jpg</url>
      <title>DEV Community: Alan Liew</title>
      <link>https://dev.to/alan_liew_888888888</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alan_liew_888888888"/>
    <language>en</language>
    <item>
      <title>How to create test cases using Equivalence Partitioning and Boundary Value Analysis test technique (Step by step)</title>
      <dc:creator>Alan Liew</dc:creator>
      <pubDate>Mon, 15 Jul 2024 06:13:30 +0000</pubDate>
      <link>https://dev.to/coingecko/how-to-create-test-cases-using-equivalence-partitioning-and-boundary-value-analysis-test-technique-step-by-step-1nkk</link>
      <guid>https://dev.to/coingecko/how-to-create-test-cases-using-equivalence-partitioning-and-boundary-value-analysis-test-technique-step-by-step-1nkk</guid>
      <description>&lt;p&gt;In the world of software testing, ensuring comprehensive coverage of test cases while maintaining efficiency is a critical challenge. Among the range of techniques available, Boundary Value Analysis (BVA) and Equivalence Partitioning (EP) stand out as fundamental methods that &lt;strong&gt;significantly enhance the effectiveness of test design.&lt;/strong&gt; These techniques help identify critical test cases and ensure that the testing process is both systematic and thorough. &lt;/p&gt;

&lt;p&gt;In this blog post, we will delve into the principles of BVA and EP, exploring how they can be applied to optimize testing efforts and improve software quality.&lt;/p&gt;

&lt;p&gt;Both are black box testing techniques. Let’s start with an explanation of the Equivalence Partitioning technique.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Equivalence Partitioning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The steps should be as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Divide the test conditions into groups or sets of partitions. All the elements under the same set of partitions are considered the same, and the system should handle them equivalently.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;A partition containing valid values is called a valid partition&lt;/li&gt;
&lt;li&gt;A partition containing invalid values is called an invalid partition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For non-numeric example:&lt;/strong&gt;&lt;br&gt;
If the fruits = apple, then print green&lt;br&gt;
If the fruits = orange, then print the orange&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqloek8dv0vkoxft1jzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqloek8dv0vkoxft1jzy.png" alt="Non Numeric Example" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above example, Apple and Orange are &lt;em&gt;valid partitions&lt;/em&gt;, while no invalid partition is specified; we assumed other fruits are &lt;em&gt;invalid partitions&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For numeric example :&lt;/strong&gt;&lt;br&gt;
Users should be able to register when they are between ages 1 and 21.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs507j4wbk43r9pr3itvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs507j4wbk43r9pr3itvs.png" alt="1 and 21 is a valid partition(able to register), while an age less than 1 and more than 21 is an invalid partition" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above example, an age between &lt;em&gt;1 and 21 is a valid partition(able to register)&lt;/em&gt;, while an age between &lt;em&gt;less than 1 and more than 21 is an invalid partition(unable to register)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. When there are multiple sets of partitions or more than one input,&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The valid partition shall combined.&lt;/li&gt;
&lt;li&gt;The invalid partition should be tested individually.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Let’s take this as an example; the requirement is to register a user email when it hits the requirements below:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It should be 6–30 characters long&lt;/li&gt;
&lt;li&gt;Should be alphanumeric&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqks0cbjkob1m36syn100.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqks0cbjkob1m36syn100.png" alt="We should be able to come up with these valid and invalid partitions." width="254" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following the No. 2 rules, we don't need to &lt;em&gt;&lt;strong&gt;create 5 test cases for 3 partitions belonging to (6–30 characters long)&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;2 partitions belonging to (should be alphanumeric)&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;We shall combine the valid partition and come out with the same test value (input) of abc123.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fih2ii7gglc965byc1o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fih2ii7gglc965byc1o.png" alt="We can satisfy the valid partition with the value of “abc123”" width="257" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, to test the invalid partition individually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdv495yzdn0330cwdhlcn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdv495yzdn0330cwdhlcn.png" alt="4 test cases will be needed to cover all partitions." width="256" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, 4 test cases are sufficient to test out all the combinations of partitions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The question may arise: why don't we combine the invalid partition?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, if we test only with less than 6 characters, the error message is “Sorry, your username must be between 6 and 30 characters long”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpbuj0r1itvfkme83udo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpbuj0r1itvfkme83udo.png" alt=" " width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, when we tested the &lt;strong&gt;invalid partition of &amp;lt;6 characters&lt;/strong&gt; and the &lt;strong&gt;invalid partition of not alphanumeric&lt;/strong&gt;, the error message was “Sorry, only letters (a-z), numbers (0–9), and periods (.) are allowed.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fus36y3keas23nkqsz6as.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fus36y3keas23nkqsz6as.png" alt=" " width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s clear that when we combine two invalid partitions to test, it’s very easy to miss out on validating the invalid partition of &amp;lt;6 characters. In this case, the test cases are not well designed.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;﻿✅ Boundary Value Analysis&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Boundary value analysis is closely related to equivalence partitioning. We can determine the boundary value by knowing the partition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will use back the same numeric example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users should be able to register when they are between ages 1 and 21&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbojno1jamnstfka64vn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbojno1jamnstfka64vn.png" alt=" " width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we know that&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;age between 1 and 21 is a valid partition (able to register),&lt;/li&gt;
&lt;li&gt;age less than 1 and more than 21 is an invalid partition (unable to register).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To determine what is the boundary values:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 1: The BVA is that the minimum and maximum values of the partition are called the partition's boundary values.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hence, the boundary values of (1 to 21) are &lt;strong&gt;1 and 21&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Next, let's find out what the 2-value BVA or 3-value BVA are.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For 2-Value BVA: This boundary value and its closest neighbor belonging to the adjacent partition will be boundary values&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oaflilchjbo77tgvazl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oaflilchjbo77tgvazl.png" alt=" " width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boundary values of (1 to 21) are the values of &lt;strong&gt;1 and 21.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(Adjacent partition) Boundary values of (1 to 21) are the values of &lt;strong&gt;0 and 22.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hence, the 2-value BVA are the values of &lt;strong&gt;0, 1, 21, 22&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;For 3-Value BVA: This boundary values and both their neighbors will be boundary values.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Boundary values of (1 to 21) are the values of &lt;strong&gt;1 and 21.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(adjacent partition) Boundary values of (1 to 21) are the values of &lt;strong&gt;0 and 22&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5f4p7m2ky3jf0zf95jmv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5f4p7m2ky3jf0zf95jmv.png" alt=" " width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boundary values and both its neighbors of (1 to 21) are the values of &lt;strong&gt;0, 1, 2, 20, 21, 22.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvxbjy4zd9v42dk8q438.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvxbjy4zd9v42dk8q438.png" alt=" " width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boundary values and both its neighbors of (0 and 22) are the values of &lt;strong&gt;1, 0, 1, 21, 22, 23.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hence, the 3-value BVA are the &lt;strong&gt;values of -1, 0, 1, 2, 20, 21, 22, 23&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;Now, you may wonder when we should use 2-value BVA or 3-value BVA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s try another requirement:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users should be able to register when their age less or equal to 21&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And somehow, developers make this mistake in the logic to be able to register when &lt;strong&gt;age = 21.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We may have overlooked and missed this bug because the 2-value BVA only tests 21; however, &lt;strong&gt;a 3-value BVA may be able to surface the issue because the value of 20 is tested.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;Boundary Value Analysis and Equivalence Partitioning are useful techniques for any software tester. By focusing on critical edge cases and grouping inputs into meaningful categories, these techniques &lt;strong&gt;avoid exhaustive testing, streamline the testing process, and uncover potential defects&lt;/strong&gt; that might otherwise go unnoticed. Embracing these methods will enhance your testing strategy and ensure that your applications meet the highest standards of quality and performance.&lt;/p&gt;

</description>
      <category>softwaretesting</category>
      <category>qa</category>
    </item>
  </channel>
</rss>
