0% found this document useful (0 votes)
18 views33 pages

Template - Unit Test Case

FPT

Uploaded by

phanthhe187053
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views33 pages

Template - Unit Test Case

FPT

Uploaded by

phanthhe187053
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 33

Guideline to make and understand Unit Test Case

1. Overview
- In the template, Unit test cases are based on functions. Each sheet presents test cases for one function.
- Cover: General information of the project and Unit Test cases
- FunctionList: The list of Classes and Functions in the document.
+ To control that the number of Unit TC meets customer's requirement or the norm, user should fill value for
'Normal number of Test cases/KLOC'.
+ Click on Function link to open the related Test cases of the function.
Note: You should create new Function sheet before creating the link
- Test Report: provive the overview results of Functions Unit test: Test coverage, Test successful coverage
(Summary, for normal/abnormal/boundary cases)
Note: Should check the formula of "Sub Total" if you add more functions

2. Content in Test function sheet


2.1 Combination of test cases.
- To verify that number of Unit TC meets customer's requirement or not. User has to fill number LOC of tested function and
number test cases/KLOC' item in FunctionList sheet, which is required by customer or normal value. The number of lacked TC
test cases' item.
- If the number of Unit TC does not meet the requirement, creator should explain the reasons.
- If the number of 'Normal number test cases/KLOC' item in FunctionList sheet is not recorded, the number in 'Lack
calculated.

2.2 Condition and confirmation of Test cases.


Each test case is the combination of condition and confirmation.
a. Condition:
- Condition is combination of precondition and values of inputs.
- Precondition: it is setting condition that must exist before execution of the test case.
Example: file A is precondition for the test case that needs to access file A.
- Values of inputs: it includes 3 types of values: normal, boundary and abnormal.
. Normal values are values of inputs used mainly and usually to ensure the function works.
. Boundary values are limited values that contain upper and lower values.
. Abnormal values are non-expected values. And normally it processes exception cases.
- For examples:
Input value belongs to 5<= input <=10.
. 6,7,8,9 are normal values.
. 5, 10 are boundary values.
. -1, 11,... are abnormal values.
b. Confirmation:
- It is combination of expected result to check output of each function.
If the results are the same with confirmation, the test case is passed, other case it is failed.
- Confirmation can include:
+ Output result of the function.
+ Output log messages in log file.
+ Output screen message...
c. Type of test cases and result:
- Type of test case: It includes normal, boundary and abnormal test cases. User selects the type based on the type of inp
- Test case result: the actual output results comparing with the Confirmation.
P for Passed and F for Failed cases.
It can 'OK' or 'NG' (it depends on habit of the teams or customers)

2.3. Other items:


- Function Code: it is ID of the function and updated automatically according to FunctionList sheet.
- Function Name: it is name of the function and updated automatically according to FunctionList sheet.
- Created By: Name of creator.
- Executed By: Name of person who executes the unit test
- Lines of code: Number of Code line of the function.
- Test requirement: Brief description about requirements which are tested in this function, it is not mandatory.
UNIT TEST CASE

Project Name Doctor management program Creator SangTV


Project Code Doctor management program Reviewer/Approver
Issue Date 6/10/2024
Document Code Doctor management program_XXX_vx.x
Version Version1

Record of change
Effective Date Version Change Item *A,D,M Change description Reference
6/13/2024 add Sheet about checkChoiceNumber, FunctionList, Test Report
checkInputInteger

6/14/2024 add Sheet about checkDuplicateDoctor FunctionList, Test Report

6/15/2024 add Sheet about checkDuplicateDoctor, FunctionList, Test Report


checkInputString

6/16/2024 add Sheet about checkInputStringForName, FunctionList, Test Report


addDoctor, updateDoctor, deleteDoctor,
searchDoctor, sortDoctors, printAllDoctors

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 3/33


UNIT TEST CASE LIST
Project Name Doctor management program
Project Code Doctor management program
Normal number of Test cases/KLOC 100
Test Environment Setup Description <List enviroment requires in this system

Requirement
No Class Name Function Name Function Code(Optional) Sheet Name
Name

public static int checkChoiceNumber(int


1 Validation checkChoiceNumber checkChoiceNumber
min, int max)

2 Validation checkInputInteger public static int checkInputInteger() checkInputInteger

public static boolean


3 ManageDoctor checkDuplicateDoctor checkDuplicateDoctor(ArrayList<Doctor checkDuplicateDoctor
> listDoctors, String code)
public static Doctor
4 ManageDoctor getDoctorByCode getDoctorByCode(ArrayList<Doctor> getDoctorByCode
listDoctors, String code)

5 Validation checkInputString public static String checkInputString() checkInputString

public static String


6 Validation checkInputStringForName checkInputStringForName
checkInputStringForName()

public static void


7 ManageDoctor addDoctor addDoctor(ArrayList<Doctor> addDoctor
listDoctors)

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 4/33


public static void
8 ManageDoctor updateDoctor updateDoctor(ArrayList<Doctor> updateDoctor
listDoctors)

public static void


9 ManageDoctor deleteDoctor deleteDoctor(ArrayList<Doctor> deleteDoctor
listDoctors)
public static void
10 ManageDoctor searchDoctor searchDoctor(ArrayList<Doctor> searchDoctor
listDoctors)
public static void
11 ManageDoctor sortDoctors sortDoctors(ArrayList<Doctor> sortDoctors
listDoctors)
public static void
12 ManageDoctor printAllDoctors printAllDoctors(ArrayList<Doctor> printAllDoctors
listDoctors)

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 5/33


Description Pre-Condition

This function checks if the


input number is within the min and max are valid values.
specified range.

This function validates and


returns an integer input No specific pre-condition
from the user.
Checks if a doctor with the
listDoctors is a valid list of Doctor
given code already exists
objects, code is not empty and not null.
in the list.
Retrieves the doctor object
listDoctors is a valid list of Doctor
from the list based on the
objects, code is not empty and not null.
provided code.
Retrieves the doctor object
listDoctors is a valid list of Doctor
from the list based on the
objects, code is not empty and not null.
provided code.
Validates and returns a
listDoctors is a valid list of Doctor
non-empty string input
objects, code is not empty and not null.
intended for a name.
Adds a new doctor to the
listDoctors is a valid list of Doctor
list after validating input
objects, code is not empty and not null.
fields.

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 6/33


Updates an existing
listDoctors is a valid list of Doctor
doctor's information in the
objects, code is not empty and not null.
list based on user input.

Deletes a doctor from the


listDoctors is a valid list of Doctor
list based on the provided
objects, code is not empty and not null.
code.
Searches for doctors in the
listDoctors is a valid list of Doctor
list based on user-
objects, code is not empty and not null.
provided text.
Sorts the list of doctors
listDoctors is a valid list of Doctor
based on user-selected
objects, code is not empty and not null.
criteria.

Prints details of all doctors listDoctors is a valid list of Doctor


in the list. objects, code is not empty and not null.

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 7/33


UNIT TEST REPORT
Project Name Doctor management program Creator SangTV
Project Code Doctor management program Reviewer/Approver
Document Code Doctor management program_Test Report_vx.x Issue Date <Date when this test report is created>
Notes <List modules included in this release> ex: Release 1 includes 2 modules: Module1 and Module2

No Function code Passed Failed Untested N A B Total Test Cases


1 checkChoiceNumber 5 1 0 4 1 1 6
2 checkInputInteger 4 0 0 2 1 1 4
3 checkDuplicateDoctor 3 0 0 3 0 0 3
4 getDoctorByCode 4 0 0 3 1 0 4
5 checkInputString 3 0 0 2 1 0 3
6 checkInputStringForName 4 0 0 2 2 0 4
7 addDoctor 1 0 0 1 0 0 1
8 updateDoctor 1 0 0 1 0 0 1
9 deleteDoctor 1 0 0 1 0 0 1
10 searchDoctor 1 1 0 2 0 0 2
11 sortDoctors 3 0 0 3 0 0 3
12 printAllDoctors 2 0 0 2 0 0 2

Sub total 32 2 0 26 6 2 34

Test coverage 100.00 %


Test successful coverage 94.12 %
Normal case 76.47 %
Abnormal case 17.65 %
Boundary case 5.88 %

Test Type
Passed Percent

Failed
6%
B
02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 6% 8/33
A
18%
Passed N A
Test Type
Passed Percent

Failed
6%
B
6%
A
18%
Passed N A

Failed B
Untested
N
Passed 76%
94%

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 9/33


public static int checkChoiceNumber(int
Function Code min, int max) Function Name checkChoiceNumber
Created By SangTV Executed By SangTV
Lines of code 17 Lack of test cases 1
Test requirement <This function is designed to validate user input to ensure it falls within a specified range [min, max] of integers.>
Passed Failed Untested N/A/B Total Test Cases
5 1 0 4 1 1 6

TC001

TC002

TC003

TC004

TC005

TC006
Condition Precondition
N/A

Input
5 O
-1 O
abc O
15 O
5 O
null O
Min
1 O O O O O
5 O
Max
10 O O O O O
5 O

Confirm Return
5 O
null O
Exception
"Not valid. Input must be integer" O
Log message
"Not valid. Input must be in range [" + min + ", " + max + "]" O O

Result Type(N : Normal, A : Abnormal, B : Boundary) N A N N B N


Passed/Failed P P P P P F
Executed Date 0 0 0 0 0 0
6 6 6 6 6 6
/ / / / / /
1 1 1 1 1 1
3 3 3 3 3 3

Defect ID D
F
I
D
0
0
1

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 10/33


checkChoiceNumber

1
ange [min, max] of integers.>
Total Test Cases
6

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 11/33


public static int
Function Code checkInputInteger() Function Name checkInputInteger
Created By SangTV Executed By SangTV
Lines of code 15 Lack of test cases N/A
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
4 0 0 2 1 1 4

UTCID01

UTCID02

UTCID03

UTCID04
Condition Precondition

Input
"5" O
"-1" O
"0" O
"abc" O

Confirm Return
5 O

Exception
"Not valid. Input must be integer" O
Log message
"Input must be > 0" O O

Result Type(N : Normal, A : Abnormal, B : Boundary) N N B A


Passed/Failed P P P P
Executed Date 0 0 0 0
6 6 6 6
/ / / /
1 1 1 1
3 3 3 3

Defect ID

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 12/33


nputInteger

N/A

Total Test Cases


4

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 13/33


public static boolean
checkDuplicateDoctor(ArrayList<
Function Code Doctor> listDoctors, String code) Function Name checkDuplicateDoctor
Created By SangTV Executed By SangTV
Lines of code 8 Lack of test cases -2.2
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
3 0 0 3 0 0 3

UTCID01

UTCID02

UTCID03
Conditio Precondition

Code
"D001" O
"D003" O
"" O

Confirm Return
1 O
0 O O
Exception

Log message

Result Type(N : Normal, A : Abnormal, B : Boundary) N N N


Passed/Failed P P P
Executed Date 0 0 0
6 6 6
/ / /
1 1 1
4 4 4
Defect ID

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 14/33


or

.2

tal Test Cases


3

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 15/33


public static Doctor
getDoctorByCode(ArrayList<Doct
Function Code or> listDoctors, String code) Function Name getDoctorByCode
Created By SangTV Executed By SangTV
Lines of code 8 Lack of test cases -3.2
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
4 0 0 3 1 0 4

UTCID01

UTCID02

UTCID03

UTCID04
Condition Precondition

Code
"D001" O
"D002" O
"D003" O
"" O

Confirm Return
"D001", "John Doe", "Cardiology", 10 O
"D002", "Jane Smith", "Neurology", 15 O
Null O O

Exception

Log message

Result Type(N : Normal, A : Abnormal, B : Boundary) N N N A


Passed/Failed
Executed Date 0 0 0 0
6 6 6 6
/ / / /
1 1 1 1
5 5 5 5
Defect ID

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 16/33


02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 17/33
public static String
Function Code checkInputString() Function Name checkInputString
Created By SangTV Executed By SangTV
Lines of code 10 Lack of test cases -2
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
3 0 0 2 1 0 3

UTCID01

UTCID02

UTCID03
Condition Precondition

Code
"abc" O
"123" O
"" O

Confirm Return
"abc" O
"123" O

Exception

Log message
"String must not empty" O

Result Type(N : Normal, A : Abnormal, B : Boundary) N N A


Passed/Failed P P P
Executed Date 0 0 0
6 6 6
/ / /
1 1 1
5 5 5
Defect ID
public static String
Function Code checkInputStringForName() Function Name checkInputStringForName
Created By SangTV Executed By SangTV
Lines of code 12 Lack of test cases -2.8
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
4 0 0 2 2 0 4

UTCID01

UTCID02

UTCID03

UTCID04
Condition Precondition

Code
"abc" O
"123" O
"@$%#" O
"" O

Confirm Return
"abc" O
"123" O

Exception

Log message
"String must not be empty" O
"" O
Result Type(N : Normal, A : Abnormal, B : Boundary) N N A A
Passed/Failed P P P P
Executed Date 0 0 0 0
6 6 6 6
/ / / /
1 1 1 1
6 6 6 6
Defect ID
public static void
addDoctor(ArrayList<Doctor>
Function Code listDoctors) Function Name checkInputStringForName
Created By SangTV Executed By SangTV
Lines of code 26 Lack of test cases 1.6
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
1 0 0 1 0 0 1

UTCID01
Condition Precondition

Code
"D004" O

Name
"New Doctor" O

Specialization
"Surgery" O

Availability
15 O

Confirm Return
"D004", "New Doctor", "Surgery", 15 O

Exception

Log message

Result Type(N : Normal, A : Abnormal, B : Boundary) N


Passed/Failed P
Executed Date 0
6
/
1
6
Defect ID
ingForName

al Test Cases
1
Function Code updateDoctor Function Name updateDoctor
Created By SangTV Executed By SangTV
Lines of code 48 Lack of test cases 3.8
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
1 0 0 1 0 0 1

UTCID01
Condition Precondition
Old code had existed

Code
"D004" O

Name
"New Doctor" O

Specialization
"Surgery" O

Availability
15 O

Confirm Return
"D004", "New Doctor", "Surgery", 15 O

Exception

Log message

Result Type(N : Normal, A : Abnormal, B : Boundary) N


Passed/Failed P
Executed Date 0
6
/
1
6
Defect ID
Function Code deleteDoctor Function Name deleteDoctor
Created By SangTV Executed By SangTV
Lines of code 18 Lack of test cases 0.8
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
1 0 0 1 0 0 1

UTCID01
Condition Precondition
Old code existed

Code
"D001" O

Confirm Return
"Delete succesful" O

Exception

Log message
"Not found doctor"

Result Type(N : Normal, A : Abnormal, B : Boundary) N


Passed/Failed P
Executed Date 0
6
/
1
6
Defect ID
Function Code searchDoctor Function Name searchDoctor
Created By SangTV Executed By SangTV
Lines of code 24 Lack of test cases 0.4
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
1 1 0 2 0 0 2

UTCID01

UTCID02
Condition Precondition
Old code existed

String
"Jane" O
"NonExistent" O

Confirm Return
""D002", "Jane Smith", "Neurology", 15" O

Exception

Log message
"Not found doctor" O

Result Type(N : Normal, A : Abnormal, B : Boundary) N N


Passed/Failed P F
Executed Date 0 0
6 6
/ /
1 1
6 6
Defect ID
Function Code sortDoctors Function Name sortDoctors
Created By SangTV Executed By SangTV
Lines of code 27 Lack of test cases -0.3
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
3 0 0 3 0 0 3

UTCID01

UTCID02

UTCID03
Condition Precondition
Old code existed

Int
1 O
2 O
3 O
Confirm Return
List Sort Doctors By Code O
List Sort Doctors By Name O
List Sort Doctors By Specialization O
Exception
"Sort successful." O O O
Log message
"Invalid option"

Result Type(N : Normal, A : Abnormal, B : Boundary) N N N


Passed/Failed P P P
Executed Date 0 0 0
6 6 6
/ / /
1 1 1
6 6 6
Defect ID
ctors

al Test Cases
3
Function Code sortDoctors Function Name sortDoctors
Created By SangTV Executed By SangTV
Lines of code 11 Lack of test cases -0.9
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
2 0 0 2 0 0 2

UTCID01

UTCID02
Condition Precondition

Empty List O
Not emply lít O

Confirm Return
"No doctors available." O
"Sort successful." O

Exception
O O
Log message
"Invalid option"

Result Type(N : Normal, A : Abnormal, B : Boundary) N N


Passed/Failed P P
Executed Date 0 0
6 6
/ /
1 1
6 6
Defect ID

You might also like