You are on page 1of 9

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.
. 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++)
Condition Valid partition Tag Invalid partition Tag Valid boundary Tag
Input number 1-6 chars A1 >6 chars C1 6 chars D1
in 0-9 digits A2 <1 char C2 1 char D2
in A-F chars A3 not in A-F char C3
in a-f chars A4 not in a-f char C4
null C5
not in 0-9 digits C6

Test case 1 A1, A2, A3


2 A1, A2,A4
3 D1, A2, A3
4 D1, A2, A4
5 A3, D2
6 A4, D2
7 E1
8 E2
9 A1,A3,C6
10 A1,A4,C6
11 E2,A2,A3,A4
11 E2,C3,D6
12 A1, A2, C3
13 A1, A2, C4
14
Invalid boundary Tag
empty E1
7 chars E2
Function Code F0001 Function Name ConvertNumber
Created By Nguyen Quang Truong Executed By Tester B
Lines of code Lack of test cases
Test requirement Check the convert a number function. The input number represented in hexa, the ouput number from will be in decimal format
Passed Failed Untested N/A/B Total Test Cases
0 0 0 5 3 4

UTCID01
UTCID02
UTCID03
UTCID04
UTCID05
UTCID06
UTCID07
UTCID08
UTCID09
UTCID10
UTCID11
UTCID12
UTCID13
UTCID14
UTCID15
UTCID16
UTCID17
UTCID18
Condition Precondition
Input number
has valid char in 1-6 chars, digit 0-9, and in A-F char 015A O
has valid char in 1-6 chars, digit 0-9, and in a-f char 0022f O
has valid 6 chars, digit 0-9, and in A-F char 12345A O
has valid 6 chars, digit 0-9, and in a-f char 12345d O
input only 1 char A-F char A O
input only 1 char a-f char f O
input value is empty O
input valid 1-6 chars, not in 0-9, and in A-F 012-1F O
input valid 1-6 chars, not in 0-9, and in a-f 49-7a O
input valid 7 chars, in 0-9, and in A-F,in a-f 9284aF8 O
input valid 1-6 chars, digit 0-9, and not in A - F 1H O
input valid 1-6 chars, digit 0-9, and not in a - f 1g O

Confirm Return
output text show 346 O
output text show 559 O
output text show 1193050 O
output text show 1193053 O
error dialog is shown O
output text show 15 O

error dialog is shown

Exception

Log message "This is invalid input" O O O O O O

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


Passed/Failed
Executed Date
Defect ID

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


will be in decimal format
tal Test Cases
UTCID19

UTCID20

UTCID21

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


Function Code 01 Function Name Sum
Created By Nguyen Quang Truong 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 8/9


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 9/9

You might also like