TEST CASES – Note That Is Constructed Using Words

0
838

Test Cases How to Write

Imagine a note that is constructed using words cut out from a book (e.g. If the book was “I am a very short and useless book” then “very useless” and “I am a book” can be constructed using words from the book while “and books” cannot).  Implement the following function [the function header is intentionally given in pseudo-code]

/* bool CanConstructNote( string note, string book) */

The function returns true if the note can be constructed using words from the book and false otherwise.

Provide as few test cases as you need to completely test the sanity of the function.  For each test case state specifically what condition it tests.

Rationale : Interviewer would like to observe interviewee’s approach while deducing the test cases of a sample problem.

Sample answer from a professional point of view

TEST REQUIREMENT

Imagine a note that is constructed using words cut out from a book (e.g. If the book was “I am a very short and useless book” then “very useless” and “I am a book” can be constructed using words from the book while “and books” cannot).

bool CanConstructNote( string note, string book)

 

TEST ENVIRONMENT

Tools Used : Microsoft Visual Studio 2005 ,Version 8.0.50727.762

Operating System : Microsoft Windows Vista Home Premium Service Pack 1

Hardware : Intel(R) Core(TM)2 Duo CPU ,T7250 @ 2.00 Ghz ,2 GB Of RAM

 

SANITY TEST CASES

<Functional Positive Tests>

CASE-1 : When note has been constructed from Book by taking fewer words.

Input :

Book “I am a very short and useless book”

Note “useless book”

Expected output : TRUE

CASE-2 : When note has been constructed from Book, and note has been constructed by taking all words from Book

Input :

Book “I am a very short and useless book”

Note “I am a very short and useless book”

Expected output : TRUE

CASE-3: When note and book have special characters

Input :

Book “[email protected]$#%^#@%$^&$^#@%$^”

Note “[email protected]!#$%#@!~# [email protected]#$^%#@%$ [email protected]#$%”

Expected output : TRUE

CASE-4: When note and book have digits

Input :

Book “Sumit has wrote test cases 6 and 12”

Note “Sumit has 6 and 12”

Expected output : TRUE

 

<Functional Negative Tests>

CASE-1: When Book is empty have no words.

Input :

 

Book “”

Note “I am a very short and useless book”

Expected output : FALSE

CASE-2: When note is empty have no words.

Input :

Book “I am a very short and useless book”

Note “”

Expected output : FALSE

CASE-3 When note and book both are empty have no words

Input :

Book “”

Note “”

Expected output : FALSE

(Its assumed that book or note can note consider the empty value)

CASE-4: When note and book are not empty but note cannot be constructed from book

Input :

Book “I am a very short and useless book”

Note “and books”

Expected output : FALSE

 

SPECIAL TEST CASES

  • Performance test cases: Test the performance of this function, when data in note or book is fairly large or note has fewer words but the book has very large data or vice versa.
  • Regression testing: If this function gets updated because of some reason or requirement change, then regression test cases required.
  • Scenario testing: Various use cases need to explore based on its actual use, and then its test cases could be written.
  • Globalization test cases: If this function supports multiple languages, as its string supports char in unicode format, so similar test needs to perform on different languages.
  • Multiple Threads: If this function will be used in Multithreading environment
  • Test Harness: Its automation also possible, when test cases randomly generate book values and note values to test consistency for all positive, negative, special test cases.

 

SHARE
Previous articleHow to Test a Soda Machine?
Next articleTEST CASES - Remove All Nodes With Even Values
Since last 15 years in different geographical locations, Sumit prepared hiring format for several hiring managers/teams to hire the balanced talents and interviewed talents on the various stages of their selection process. He also interviewed by hundreds of companies in different geographical locations.His best conclusion for hiring teams and candidate is to prepare in advance. Here ‘advance’ means keep your interview book ready and continue to update it even you are not going to interview candidates or applying for any job in next six months.