Template_Unit Test Case (Autosaved)

You might also like

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 40

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 fill value of 'Normal number test cases/KLO
- 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 cases' is not 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 input data.
- 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.
Normal number test cases/KLOC' item in FunctionList sheet, which is required by customer or normal value. The number of lacked TC is shown in 'Lack of test cases' item.
est cases' item.
UNIT TEST CASE

Project Name online shop Creator


Project Code SWT_LAB4 Reviewer/Approver
Issue Date
Document Code SWT_LAB4_v1.0
Version

Record of change
Effective Date Version Change Item *A,D,M Change description

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


ST CASE

minhdhn
minhdhn
18/3/2024

Reference

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


UNIT TEST REPORT
Project Name online shop Creator minhdhn
Project Code SWT_LAB4 Reviewer/Approver minhdhn
Document Code SWT_LAB4_Test Report_vx.x Issue Date 18/3/2024
Notes

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


1 Function1 4 0 0 0 0 0 4
2 Function2 2 1 0 4 0 0 4
3 Function3 1 1 0 0 0 0 3
4 Function4 2 2 0 9
5 Function5 3 0 0 6
6 Function6 5 1 0 8
7 Function7 4 1 0 8
8 Function8 2 1 0 7
9 Function9 3 0 0 2
10 Function10 2 1 0 5
11 Function11 1 0 0 2
12 Function12 1 0 0 2
Sub total 30 8 0 4 0 0 60

Test coverage 63.33 %


Test successful coverage 50.00 %
Normal case 6.67 %
Abnormal case 0.00 %
Boundary case 0.00 %

Passed Percent Test Type

21%

Passed N
Failed A
Untested B

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


21%

Passed N
Failed A
Untested B

79%
4

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


UNIT TEST CASE LIST
Project Name online shop
Project Code SWT_LAB4
Normal number of Test cases/KLOC 100
Test Environment Setup Description

Requirement
No Class Name Function Name Sheet Name Description
Name
1 ProductDBContext getAllProduct Function1 View all products
2 ProductDBContext getTotalProduct Function2 View Quantity of all products in database
3 ProductDBContext getProductById Function3 Get the product by it's id
4 ProductDBContext insertProduct Function4 insert product into the system
5 ProductDBContext deleteProduct Function5 delete product out of the system
6 ProductDBContext updateProduct Function6 Update product in the system
7 AccountDBContext insertAccount Function7 Insert account into the system
8 AccountDBContext updateAccount Function8 Update account in the system
9 AccountDBContext updatePassword Function9 Update account'password in the system
10 AccountDBContext checkAccountExist Function10 Check if the account exist
11 AccountDBContext getAccountById Function11 View account by id
12 CategoryDBContext getCategoryById Function12 Get Category By Id

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


Pre-Condition
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server
Can connect with server

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


Function Code #NAME? Function Name getAllProduct
Created By minhdhn Executed By
Lines of code 30 Lack of test cases -1
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
0 0 4 0 0 0 4

UTCID01
UTCID02
UTCID03
UTCID04
Condition Precondition
product exist O
product not exist O
Confirm Return
null O
product O
Log message
"success" O
"there no product" O
Result Type(N : Normal, A : Abnormal, B : Boundary) A N N N
Passed/Failed P P P P
Executed Date 0 0 0 0
Defect ID 2 2 2 2
/ / / /
2 2 2 2
6 6 6 6

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


Function Code #NAME? Function Name getTotalProduct
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases 26
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested N/A/B Total Test Cases
4 0 0 4 0 0 4

UTCID01
UTCID02
UTCID03
UTCID04
Condition Precondition
Can connect with server

Input
"1" O
"0" O
null O
"-1" O
Confirm Return
1 O
0 O
null O

Exception

Log message
"success" O
"Error" O O
"there no product in list" O
Result Type(N : Normal, A : Abnormal, B : Boundary) N N N N
Passed/Failed P P P P
Executed Date 0 0 0 0
2 2 2 2
/ / / /
2 2 2 2
6 6 7 7

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


Defect ID

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


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

UTCID01
UTCID02
UTCID03
ConditionPrecondition
id Exist O
id not Exist O O

Input1
"1" O
"100" O
"-1" O
Confirm Return
product O
null O O
Exception

Log message
"success" O
"there no product" O
junit.framework.AssertionFailedEr O
ror
Result Type(N : Normal, A : Abnormal, B : Boundary) N N N
Passed/Failed P P P
Executed Date 0 0 0
Defect ID 2 2 2
/ / /
2 2 2
6 6 6

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


02ae-BM/PM/HDCV/FSOFT v2/1 Internal use 16/
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
0 0 9

UTCID01

UTCID02

UTCID03

UTCID04

UTCID05

UTCID06
Condition Precondition

Name
"Test Product" O O
"32894798" O O
!@##$%%^" O O
Price
1000000 O O O
-11111 O O
1 O
Title
"Iphone" O
"03129370" O O O
"%$&%^%&" O O
image
test_image_url.jpg O O
3.48957E+11 O O O
^(*&*()_(_()* O
Description
98437043 O O
*(&)&)*&)* O O
hjghjghygjhgj O O
Confirm
Return
Product O
null O O O O O
Exception

Log message
"success" O
"Error" O O O O O
Result Type(N : Normal, A : Abnormal, B : Bound N N N N N N
Passed/Failed P P P P P P
Executed Date 0 0 0 0 0 0
2 2 2 2 2 2
/ / / / / /
2 2 2 2 2 2
6 6 7 7 7 7
Defect ID
getProductById

21

N/A/B Total Test Cases


0 0 0 9
UTCID07

UTCID08

UTCID09

O
O
O

O
O O

O
O
O

O O

O
O
O

O
O O

O
O O
N N N
P P P
0 0 0
2 2 2
/ / /
2 2 2
7 7 7
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
5 1 0

UTCID01

UTCID02

UTCID03

UTCID04

UTCID05

UTCID06
Condition Precondition
id Exist O O O
Id Not Exist O O O

Input
"1" O
"0" O
"-1" O
dsjfjhdj O
&*^&^& O
null O
Confirm
Return
1 O O O
FALSE O O O
Exception

Log message
"Delete success" O
"Error" O O O O
"there no product in list" O
Result Type(N : Normal, A : Abnormal, B : Bou N N N N N B
Passed/Failed P P P P P F
Executed Date 0 0 0 0 0 0
2 2 2 2 3 3
/ / / / / /
2 2 2 2 0 0
6 6 7 8 1 2
Defect ID D
F
I
D
0
0
2
getTotalProduct

24

N/A/B Total Test Cases


5 0 1 6
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
5 4 0

UTCID01

UTCID02

UTCID03

UTCID04

UTCID05

UTCID06
Condition Precondition

id
"1" O O
"lskadj" O O
"$%^&*" O O
name

"samsun" O O O O
"" O O
price
100000 O O O
-1 O O O
title
"it good" O O O
null O O O
Description
Made in vietnam O O
6.57648E+11 O O
%&&%&*%* O O
Confirm
Return
1 O O O
FALSE O O O
Exception

Log message
" Update success" O O
"Error" O O O O
Result Type(N : Normal, A : Abnormal, B : Bound N N N N N B
Passed/Failed P P P P P F
Executed Date 0 0 0 0 0 0
2 2 2 2 3 3
/ / / / / /
2 2 2 2 0 0
6 6 7 8 1 2
Defect ID D
F
I
D
0
0
2
getTotalProduct

21

N/A/B Total Test Cases


5 0 4 9
UTCID07

UTCID08

UTCID09

O
O
O

O
O O

O
O O

O O O

O O
O

O
O O

O O O
B B B
F F F
0 0 0
3 3 3
/ / /
0 0 0
2 2 2
D D D
F F F
I I I
D D D
0 0 0
0 0 0
2 2 2
Function Code Function6 Function Name
Created By ToanHM Executed By
Lines of code 24 Lack of test cases
Test requirement
Passed Failed Untested
8 6 0

UTCID01

UTCID02

UTCID03

UTCID04

UTCID05

UTCID06
Condition Precondition
username
"minh" O O
"@@!$@!%#%" O O
"1111111" O O
password
"123" O
"@@!$@!%#%" O O O
"ádssadadfdsf1" O O
email
minh@gmail.com O O O
sjdkahkajsd O O O
Confirm Return
1 O O O
FALSE O O O
Exception
java.lang.RuntimeException: Uncompilable
O
code - incompatible types: int cannot be

Log message
Insert account successful! O O O
Cannot insert account! O O O
Result Type(N : Normal, A : Abnormal, B : Boundar N A A A A A
Passed/Failed P F P P F P
Executed Date 0 0 0 0 0 0
2 2 2 2 2 2
/ / / / / /
2 2 2 2 2 2
6 6 6 6 6 6
Defect ID D D
F F
0 0
0 0
1 1
8 9
insertAccount
ToanHM
-1.328

N/A/B Total Test Cases


1 13 0 14
UTCID07

UTCID08

UTCID08

O
O
O

O O O

O O
O

O O
O

O O
O
A A A
F P P
0 0 0
2 2 2
/ / /
2 2 2
6 6 6
D
F
0
0
2
0
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
7 0 0

UTCID01

UTCID02

UTCID03

UTCID03

UTCID03

UTCID03
Condition Precondition
Can connect with server

username
"minh" O
"" O
"inh" O O O O
email

min@gmail.com O O O O
aslkdjsakldjfklahf O O
Phone
985880642 O O
5463465536456 O O
gfdgsfdgfsg O
*(&(*)&)* O
Confirm
Return
1 O O
FALSE O O O O
Exception

Log message
"success" O
"Error" O O O O
"there no product in list" O
Result Type(N : Normal, A : Abnormal, B : Boundary) N N N N N N
Passed/Failed P P P P P P
Executed Date 0 0 0 0 0 0
2 2 2 2 2 2
/ / / / / /
2 2 2 2 2 2
6 6 7 7 7 7
Defect ID
getTotalProduct

23

N/A/B Total Test Cases


7 0 0 7
UTCID03

N
P
0
2
/
2
7
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
2 0 0

UTCID01

UTCID02
Condition Precondition
Can connect with server

username
null O
"minh" O
new password

"minh123" O
null O
Confirm
Return
1 O
FALSE O
Exception

Log message
"Update success" O
"Error" O
Result Type(N : Normal, A : Abnormal, B : Bou N N
Passed/Failed P P
Executed Date 0 0
2 2
/ /
2 2
6 6
Defect ID
getTotalProduct

28

N/A/B Total Test Cases


2 0 0 2
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
5 0 0

UTCID01

UTCID02

UTCID03

UTCID04

UTCID05
Condition Precondition
Can connect with server

username
"minh" O
null O
9608709 O
lfkghj O
()*&(* O
Confirm
Return
1 O
FALSE O O O O
Exception

Log message
"success" O
"Error" O O O O
Result Type(N : Normal, A : Abnormal, B : Bou N N N N N
Passed/Failed P P P P P
Executed Date 0 0 0 0 0
2 2 2 2 2
/ / / / /
2 2 2 2 2
6 6 6 6 6
Defect ID
getTotalProduct

25

N/A/B Total Test Cases


5 0 0 5
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
2 0 0

UTCID01

UTCID02
Condition Precondition
id Exist O
id not Exist O

ID
"0" O
"1" O
Confirm
Return
Account O
null O
Exception

Log message
"success" O
"Error"

"there no product in list" O


Result Type(N : Normal, A : Abnormal, B : Bou N N
Passed/Failed P P
Executed Date 0 0
2 2
/ /
2 2
6 6
Defect ID
getTotalProduct

28

N/A/B Total Test Cases


2 0 0 2
Function Code #NAME? Function Name
Created By <Developer Name> Executed By
Lines of code 300 Lack of test cases
Test requirement <Brief description about requirements which are tested in this function>
Passed Failed Untested
2 0 0

UTCID01

UTCID02
Condition Precondition
id Exist O
id not Exist O
id
"1" O
"0" O
Confirm
Return
category O
null O
Exception

Log message
"success" O
"Error"

"there no product in list" O


Result Type(N : Normal, A : Abnormal, B : Bou N N
Passed/Failed P P
Executed Date 0 0
2 2
/ /
2 2
6 6
Defect ID
getTotalProduct

28

N/A/B Total Test Cases


2 0 0 2
Function Code #NAME? Function Name getAllProduct
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
0 0 15 0 0 0 15

UTCID01
UTCID02
UTCID02
UTCID02
UTCID02
UTCID02
UTCID07
UTCID08
UTCID09
UTCID10
UTCID11
UTCID12
UTCID13
UTCID14
UTCID15
Condition Precondition

a
-2 O
-1 O
0 O O O
1 O O
b
0 O O
-2 O O O
2 O
c
0 O
1 O O O
3 O
5 O

Confirm Return
list
null O O O

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


size = 0 O
{-1/2} O
{1,1} O
{1,-3} O
Exception

Log message
"please input a>= -1" O

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


Passed/Failed
Executed Date 0 0 0 0 0 0 0
Defect ID 2 2 2 2 2 2 3
/ / / / / / /
2 2 2 2 2 2 0
6 6 6 6 6 6 3

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

You might also like