You are on page 1of 17

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 an
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 of test ca

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 <Project Name> Creator


Project Code <Project Code> Reviewer/Approver
Issue Date <Date when this test report is created>
Document Code <Project Code>_XXX_vx.x
Version

Record of change
Effective Date Version Change Item *A,D,M Change description Reference
<Date when these <List of documents which are refered in this version.>
changes are effective>

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


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

Requirement Function
No Class Name Function Name Sheet Name Description
Name Code(Optional)
1 Class1 Function A Function1 Function1
2 Class2 Function B Function2 Function2
3 Class3 Function C Function3 Function3

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


Pre-Condition

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


UNIT TEST REPORT
Project Name <Project Name> Creator
Project Code <Project Code> Reviewer/Approver
Document Code <Project Code>_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 Function1 12 2 -9 11 3 1 5
2 Function2 12 3 0 12 2 1 15
3 Function3 12 2 1 12 2 1 15

Sub total 36 7 -8 35 7 3 35

Test coverage 122.86 %


Test successful coverage 102.86 %
Normal case 100.00 %
Abnormal case 20.00 %
Boundary case 8.57 %

Test Type
Passed Percent

Untested
16%
B
7%
A
16%
Passed N A
Failed
14% Failed B
Passed Untested
71% N
78%

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


14% Failed B
Passed Untested
71% N
78%

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


Function Code Function1 Function Name =FunctionList!D11
Created By <Developer Name> Executed By
Lines of code 100 Lack of test cases 5
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
12 2 -9 11 3 1 5

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
Condition Precondition
Can connect with server

Date
29 O O
30
31
Month
2 O
3 O
4
Year
2000 O
2009 O

Confirm Return
T O O
F
Exception

Log message
"success"
"input1 is null"
Result Type(N : Normal, A : Abnormal, B : Boundary) A N N N N B A N N N N N A N N
Passed/Failed P P P P P F F P P P P P P P
Executed Date 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 2 2 2 3 3 3 3 3 3 3 3 3 3 3
/ / / / / / / / / / / / / / /
2 2 2 2 0 0 0 0 0 0 0 0 0 1 1
6 6 7 8 1 2 3 4 5 6 7 8 9 0 1

Defect ID D D D D D D D D D D
F F F F F F F F F F
I I I I I I I I I I
D D D D D D D D D D
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 1
2 4 5 6 7 8 9 0 1 2

02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 8/17


Function Code =FunctionList!E12 Function Name Function B
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases 15
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
12 3 0 12 2 1 15

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
UTCID06
UTCID07
UTCID08
UTCID09
UTCID10
UTCID11
UTCID12
UTCID13
UTCID14
UTCID15
Condition Precondition
Can connect with server

Input1
"1"
""
null
Input2
>=5 & <= 10
5
10

Confirm Return
1
2
Exception

Log message
"success"
"input1 is null"
Result Type(N : Normal, A : Abnormal, B : Boundary) N N N N N B A N N N N N A N N
Passed/Failed P P P P P F F P P P P P F P P
Executed Date 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Defect ID 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3
/ / / / / D/ D/ D/ D/ D/ D/ D/ D/ D/ D/
2 2 2 2 0 F0 F0 F0 F0 F0 F0 F0 F0 F1 F1
6 6 7 8 1 I
2 I
3 I
4 I
5 I
6 I
7 I
8 I
9 I
0 I
1
D D D D D D D D D D
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 1
2 4 5 6 7 8 9 0 1 2

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


Function Code Function3 Function Name Function C
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases 15
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
12 2 1 12 2 1 15

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
UTCID06
UTCID07
UTCID08
UTCID09
UTCID10
UTCID11
UTCID12
UTCID13
UTCID14
UTCID15
ConditionPrecondition
Can connect with server

Input1
"1"
""
null
Input2
>=5 & <= 10
5
10

Confirm Return
1
2
Exception

Log message
"success"
"input1 is null"
Result Type(N : Normal, A : Abnormal, B : Boundary) N N N N N B A N N N N N A N N
Passed/Failed P P P P P F F P P P P P P P
Executed Date 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Defect ID 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3
/ / / / / D/ D/ D/ D/ D/ D/ D/ D/ D/ D/
2 2 2 2 0 F0 F0 F0 F0 F0 F0 F0 F0 F1 F1
6 6 7 8 1 I
2 I
3 I
4 I
5 I
6 I
7 I
8 I
9 I
0 I
1
D D D D D D D D D D
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 1
2 4 5 6 7 8 9 0 1 2

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


Function Code Function3 Function Name Function C
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases 15
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B
12 2 1 10 4 1

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
UTCID06
UTCID07
UTCID08
UTCID09
ConditionPrecondition
Can connect with server

user_email
null O
"existing emal" O O
"non-existing email" O

password
null O
"valid password" O O O
"invalid passoword"

Confirm Return
("1", "kim", "female", "hanoi", "valid password", "existing email", "…") O
null O O O
Exception
SQLException O
Log message
"User SQLException" O

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


Passed/Failed P P P P P F F P P
Executed Date
Defect ID

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


Function C

15

Total Test Cases


15
UTCID10
UTCID11
UTCID12
UTCID13
UTCID14
UTCID15

N N N A N N
P P P P P

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


Function Code performOperation Function Name performOperation()
Created By Jane Doe Executed By 10/28/2023
Lines of code 35 Lack of test cases -3.5
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
0 0 7 0 0 0 7

UTCID01
UTCID02
UTCID02
UTCID02
UTCID02
UTCID02
UTCID07
Condition Precondition
N/A

num1
-2 O O
-1 O
0 O
1 O O O
num2
0 O O O
-2 O O
2 O O
operation
null O
"addition" O
"subtraction" O
"multiplication" O
"division" O O
"some-nonsense-text" O

Confirm Return
int
0 O O O
correct result O O O O

Exception
N/A
Log message
"Error: Operation cannot be null." O
"Performed addition: " O
"Performed subtraction: " O
"Performed multiplication: " O
"Performed division: " O
"Error: Division by zero is not allowed." O

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


"Error: Unsupported operation - " O
Result Type(N : Normal, A : Abnormal, B : Boundary) A N N N N A A
Passed/Failed
Executed Date
Defect ID

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


peration()

3.5

otal Test Cases


7

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


02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 16/17
Function Code checkPosInt Function Name checkPosInt
Created By Tam Nguyen Executed By
Lines of code 15 Lack of test cases -3.5
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
0 0 5 1 4 0 5

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
ConditionPrecondition
N/A

student name, age


Student s1 ("Kim", 40) O
{} O
"12" O
"-12" O
null O

Confirm Return
0 O O O O
12 O
Exception
NumberFormatException O O O
Log message
"input must be a positive integer" O
"input must be an integer O O O
successful O
Result Type(N : Normal, A : Abnormal, B : Boundary) A A N A A
Passed/Failed
Executed Date
Defect ID

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

You might also like