You are on page 1of 6

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.
number test cases/KLOC' item in FunctionList sheet, which is required by customer or normal value. The number of lacked TC
test cases' item.
-- IfIfthe
thenumber
numberof of
Unit'Normal
TC doesnumber
not meet thecases/KLOC'
test requirement,item
creator should explain
in FunctionList the reasons.
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.
. 1,2,3,4,5,6,7,8 are normal values.
. 0, 9, a, f, A, F are boundary values.
. -1, m,... 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.
Yêu cầu: Thiết kế Unit Test case cho phần code dưới đây theo phương pháp Black box testing
(3 kỹ thuật). Comment tại từng test case là test case này test theo kỹ thuật nào.
VD: Test case 1: Test theo kỹ thuật Spec derive test - input dữ liệu thường.

- HexToDec là ứng dụng nhỏ chuyển đổi một số có hệ cơ số 16 thành hệ cơ số


10
- Nhập số có hệ cơ số 16 vào ô Hex, sau đó bấm nút Hex to Dec, ô Dec sẽ hiển
thị số Hex vừa nhập dưới dạng số thập phân
- Giá trị đầu vào đúng như sau:
+ số dương, nhỏ hơn hoặc bằng 6 chữ số
+ số ở hệ cơ số 16: '0'~'9', 'a'~'f', 'A'~'F'
- Nếu giá trị đầu vào không đúng, chương trình sẽ thông báo lỗi nhập liệu

Yêu cầu:
Thiết kếUnit Test case cho phần code dưới đây theo phương pháp White box testing
(Path coverage).
Vẽra sơ đồ(Ko cần phải show), comment trong code của từng test cases.
VD: Test case 1: A-> B -> C->D

i++)
Function Code Lab3 Function Name Calculate
Created By SangNV Executed By nguyen duc cuong
Lines of code Lack of test cases
Test requirement Develop Test Case to cover statement, path , branch for the program mentioned in the provided document
Passed Failed Untested N/A/B Total Test Cases
7 5 2 4 2 6 14

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
UTCID06
UTCID07
UTCID08
UTCID09
UTCID10
UTCID11
UTCID12
UTCID13
UTCID14
UTCID15
UTCID16
UTCID17
UTCID18
UTCID19

UTCID20

UTCID21
Condition Precondition
input1 (200,1000,1900,0.5) O
(10,90,900,0.2) O
(30,2000,800,0.5) O
(4,9,4800,1) O
(4,9,2000,200) O
(6,-5,30,1) O
(250,200,2000,0.6) O
(20,500,22000,0.1) O
(3,20,11000,0.5) O
(2,1000,1500,1) O
(240,150,1900,0.2) O
(240,10000000000,1600,0.7) O
(20,"M",1500,0.65) O
(1,100,2500,0.9) O

Confirm Return 0.6 O


0.39 O
0.75 O
1.848 O
-1 O
-1 O
-1 O
-1 O
0.6435 O
1.32 O
0.288 O
0.84 O
1.4256 O

Exception

Log message "Invalid input" O

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


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

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


Function Code 01 Function Name Sum
Created By <Developer Name> Executed By
Lines of code Lack of test cases
Test requirement Return sum of input1 and input2
Passed Failed Untested N/A/B Total Test Cases
0 0 10 2 2 6 10

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
UTCID06
UTCID07
UTCID08
UTCID09
UTCID10
UTCID11
UTCID12
UTCID13
UTCID14
UTCID15
Conditio Precondition 0 O
9 O
a O
f O
Input1 A O
F O
d O
E O

Input2 m O
-1 O

Confirm Return 0 O
9 O
10 O
15 O
10 O
15 O
13 O
14 O

Exception

Log message "This is invalid input" O O

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


Result Type(N : Normal, A : Abnormal, B : Boundary) B B B B B B N N A A
Passed/Failed
Executed Date
Defect ID

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

You might also like