You are on page 1of 36

1

NGN HNG CU HI THI T LUN


Tn hc phn: m bo cht lng phn mm
Ngnh o to:

M hc phn: INT 416


Trnh o to:

Mu xm: b qua
Mu : bt buc
Cn li: cn hc
1. Ngn hng cu hi thi

Cu hi loi 1 im
Cu hi 1.1: Li phn mm l g? Nguyn nhn gy ra li phn mm?
Li phn mm - Software Error : L cc phn code sai do li c php, logic hoc li do phn
tch, thit k.

Cu hi 1.2: C s kim nh cht lng phn mm?


Cu hi 1.3: m bo phn mm xut pht t u? Tin trin ca n nh
th no?
Cu hi 1.4: K ra cc o c trng cht lng chnh ca McCall? Gii
thch ni dung ca n?
McCall xut 22 o sau:
(1) kim ton c: c th kim tra d dng v vic tun th cc chun
(2) chnh xc: chnh xc ca tnh ton v iu khin
(3) tng ng giao tip: mc s dng cc giao din, giao thc v gii thng chun.
(4) y : mc theo cc vic ci t y cho cc chc nng yu cu c t ti.
(5) phc tp: trnh dng chng trnh c phc tp cao
(6) sc tch (conciseness): gn ca chng trnh di dng s dng m.
(7) ho hp (consistancy): vic dng k thut thit k v t liu thng nht trong ton b
chng trnh.
(8) tng ng d liu: vic dng cc cu trc v kiu d liu chun trong ton b chng trnh
(9) dung th li: nhng hng hc xut hin khi chng trnh gp phi mt li c chp nhn.
(10) hiu qa thc hin: hiu nng khi chy ca chng trnh
(11) khuch trng c:Mc theo thit k kin trc, d liu hay th tc c th c m
rng.
(12) khi qut: rng ri ca ng dng tim nng ca cc thnh phn chng trnh.
(13) c lp phn cng: mc theo phn mm tch bit c vi phn cng m n vn
hnh.
(14) Trang b ngh (instrumentation):mc theo chng trnh iu phi thao tc ca
ring n v xc nh cc li xut hin
(15) o moun ho: s c lp chc nng ca cc thnh phn trong chng trnh

2
(16) d thao tc: Vic d vn hnh trong chng trnh
(17) an ninh: c sn c ch kin sot hay bo v chng trnh v d liu.
(18) t to ti liu (self-doccumentation): mc theo m gc cung cp ti liu c ngha.
(19) n gin - d hiu: mc theo ngi ta c th hiu c chng trnh khng kh
khn.
(20) c lp h thng phn mm: mc theo chng trnh c c lp vi cc tnh nng
ngn ng lp trnh, cc c trng h iu hnh v nhng rng buc mi trng khng chun khc.
(21) ln vt c: kh nng theo di cc du vt ca mt biu din thit k hay thnh phn ca
chng trnh thc hin so vi yu cu
(22) o kh nng hun luyn: Mc theo phn mm tr gip lm cho ngi dng mi
dng c h thng.

Cu hi 1.5: Nu cc c trng cht lng theo Hawlett? Gii thch ni


dung mi loi?
Cu hi 1.6: Trnh by k thut Walkthrough
Cu hi 1.7: Trnh by k thut Inspection
Cu hi 1.8: Trnh by tm tt SQA trong tiu chun ISO 9000-3
Cu hi 1.9: Trnh by cc c tnh cht lng ISO 9126.
Cu hi 1.10: Trnh by tm tt SQA trong tiu chun IEEE std1028
Cht lng phn mm l:
(1) Mc m mt h thng, thnh phn, hay tin trnh p ng c c t yu cu _by
Philip Crosby
(2) Mc m mt h thng, thnh phn, hay tin trnh p ng c nhu cu/mong mun
ca khch hng/ngi dng. _ by Joseph M. Juran
Lp k hoch v ci t mt cach h thng!
ch ra tin v v truyn ti s tin cy ca phn mm ang phat trin
Vi tin trnh phat trin phn mm
mt phng php lun; mt cch thc lm;
Vi c t yu cu k thut phi c.
SQA bao gm c tin trnh phat trin v c th c bo tr di hn. Do vy, ta cn xem xt vn v
cht lng cho c phat trin v bo tr trong SQA
Hnh ng SQA phi bao gm c lp lch v lp ngn sach.
SQA phi ch ra cac vn ny sinh khi khng ap ng c rng buc thi gian b bt chc
nng? Rng buc ngn sach c th tho hip c khi ngun lc c phn b b l khng cho
phat trin v/hoc bo tr.

Cu hi 1.11: Trnh by cc mc tiu chun trong CMM?


CMMI vit tt cho Capability Maturity Model Integration - M hnh trng thnh nng lc tch hp
- v l khun kh cho ci tin qui trnh phn mm. N da trn khi nim v cc thc hnh tt nht
v k ngh phn mm v gii thch k lut m cc cng ty c th dng ci tin cc qui trnh ca h
CMM bao gm 5 levels v 18 KPAs (Vng quy trnh quan trng - Key Process Area).
Ni cch khc mi mt level u tun theo mt chun mc cao hn. Mun t c chun cao
hn th cc chun ca cc level trc phi tho mn. Mi level u c c im ch quan trng
ca n cn cc doanh nghip phi p ng c.

3
Level 1 th khng c KPAs no c
Level 2 : c 6 KPAs
Level 3: c 7 KPAs
Level 4: c 2 KPAs
Level 5: c 3 KPAs
18 KPAs ca CMM c u c 5 thuc tnh(chc nng) chung trong c cc qui nh v
key pratice l nhng hng dn v cc th tc(procedure), qui tc(polities), v hot ng
(activites)ca tng KPA.
M hnh ny xc nh nm cp ca CMM i vi mt cng ty : Khi u (ln xn, khng
theo chun) - Lp (qun l d n, tun th quy trnh) - Xc lp (th ch ha) - Kim sot (nh
lng) - Ti u (ci tin quy trnh).

Level 1
Level 1 l bc khi u ca CMM, mi doanh nghip, cng ty phn mm, c nhm, c
nhn u c th t c. lever ny CMM cha yu cu bt k tnh nng no. V d: khng yu
cu quy trnh, khng yu cu con ngi, min l c nhn, nhm, doanh nghip u lm v phm
mm u c th t ti CMM ny.
Level 2
C 6 KPA n bao gm nh sau:
- Requirement Management (Ly yu cu khch hng, qun l cc yu cu )
- Software Project Planning (Lp cc k hoch cho d n)
- Software Project Tracking (Theo di kim tra tin d n)
- Software SubContract Managent (Qun tr hp ng ph phn mm)
- Software Quality Assurance (m bo cht lng sn phm)
- Software Configuration Management (Qun tr cu hnh sn phm => ng yu cu ca
khch hng khng)
Level 3

4
Cc vng tin trnh ch cht mc 3 nhm vo c hai vn v d n v t chc, v mt t
chc (cng ty) to nn cu trc h tng th ch cc qu trnh qun l v sn xut phn mm hiu qu
qua tt c cc d n. Chng gm c Tp trung Tin trnh T chc (Organization Process Focus),
Phn nh Tin trnh T chc (Organization Process Definition), Chng trnh o to (Training
Program), Qun tr Phn mm Tch hp (Integrated Software Management), Sn xut Sn phm
Phn mm (Software Product Engineering), Phi hp nhm (Intergroup Coordination), v Xt duyt
ngang hng (Peer Reviews).
Level 4
Cc vng tin trnh ch yu mc 4 tp trung vo thit lp hiu bit nh lng ca c qu
trnh sn xut phn mm v cc sn phm phn mm ang c xy dng. l Qun l qu trnh
nh lng (Quantitative Process Management) v Qun l cht lng phn mm (Software Quality
Management).
Lc lng lao ng lm vic theo i, nhm v c qun l mt cch nh lng.
Level 5
Cc vng tin trnh ch yu mc 5 bao trm cc vn m c t chc v d n phi nhm ti
thc hin hon thin qu trnh sn xut phn mm lin tc, o m c. l Phng nga li
(Defect Prevention), Qun tr thay i cng ngh (Technology Change Management), v Qun tr
thay i qu trnh (Process Change Management) t c level 4 th phi o lng v chun
ha. o lng hiu qu p ng cng vic, chun hac pht trin cc k nng, nng lc ct li.

Cu hi 1.12: Mc tiu ca SQA l g? Cc hot ng chnh m bo cht


lng phn mm l nhng hot ng no?
m bo cht lng phn mm l cc hot ng nhm mc tiu l sn xut ra phn mm c cht
lng cao.
C 7 hot ng chnh:
(1) p dng cng ngh k thut hiu qu (phng php, cng c)
(2) Tin hnh r sot k thut chnh thc
(3) Thc hin kim th nhiu tng
(4) Tun theo cc chun pht trin
(5) Kim sot ti liu Fm v thay i ca chng
(6) Thc hin o lng
(7) Bo co v bo qun l cc bo co.

Cu hi 1.13: Kho st nhu cu SQA gm nhng ni dung g? Nhm tr li


cc cu hi g?
- Gm ba ni dung nhm tr li ba cu hi
+ Kim k cc chnh sch SQA: chnh sch, th tc, chun no c trong cc pha pht
trin?
+ nh gi vai tr ca k ngh phn mm, bo m cht lng trong t chc hin ti c
quyn lc n u?
+ nh gi mi quan h SQA: Giao din chc nng gia SQA vi cc n v khc nh th
no? Vi cc ngi thc hin r sot k thut chnh thc, qun l cu hnh v th nghim.
Mt khi ba cu hi trn c tr li th mc mnh hay yu c minh bch.
- Nu c nhu cu SQA th cn phi tin hnh nh gi cn thn bng quy tc b phiu.

Cu hi 1.14: Trnh by cu trc t chc n v SQA?


Cu hi 1.15: Ca kim th l ci g? Mc tiu thit k ca kim th?
- Mt ca kim th (test case) trong cng ngh phn mm l mt tp hp cc iu kin hay cc bin
theo mt th nghim s xc nh xem mt ng dng hoc h thng phn mm ang lm vic
mt cch chnh xc hay khng.
- Thit k ca kim th thng vi mong mun tm ra c nhiu sai nht vi n lc v thi gian l
ngn nht.
- Vic kim th th c nhng k thut khc nhau, do vy theo mnh, cc bc xy dng cc ca n
cng s ty theo tng phng php, k thut. V ny th mi l theo kin c nhn ca mnh, nu
bn c cu tr li c th ng gp cho mi ngi cng nm c.

Cu hi 1.16: Kim th hp trng l g? Nu cc c trng ca n?


- Khi nim: Kim th hp trng (White-box Testing): L hnh thc kim th m kim th vin bit
c cc cu trc bn trong ca chng trnh (m ngun, x l d liu, ). Vic kim th c da
trn cc phn tch v cu trc bn trong ca thnh phn/h thng.
- i tng kim th: Kim th trc tip trn m ngun (mc modul n v)
- Khm xt cc chi tit th tc (thut ton), cc con ng logic (lung iu khin), cc trng thi
ca chng trnh (d liu)
- Vn tr ngi: S con ng logic l ln. Chng hn chng trnh nh ch c 100 dng PASCAL
vi mt vng lp th s con ng c th xt ln n 1014 v gi s mt kim th ht 1ms th tn
3170 nm lm kim th cho tt c cc con ng .
- Cch thc: S dng cu trc iu khin ca thit k th tc hnh thnh cc ca kim th
- Ni dung kim th (kim th ci g?):
+ Mi lnh c thc hin (y )
+ Mi iu kin c kim tra (r nhnh)
+ Mi chu trnh c duyt qua (lp li)
+ Mi cu trc d liu c dng (d liu)
+ Mi tin trnh t u n kt thc (tng lung iu khin)
- Yu cu t ra:
+ Mi con ng c lp trong modul cn c thc hin t nht mt ln.
+ Mi rng buc logic c thc hin c hai pha ng (true) v pha sai (false)
+ Tt c cc vng lp bin ca n v c cc bin vn hnh phi c thc hin
+ Mi cu trc d liu ni ti c dng m bo tnh hiu lc ca n.
- L do kim th hp trng:
+ Cc sai logic v gi thit khng ng n t l nghch vi xc sut mt con ng logic c
thi hnh.
+ Thc t: mi con ng logic u c th c thi hnh trn 1 c s nht nh (ta cho rng 1 con
ng logic no l khng th c thi hnh).
+ C nhng sai chnh t c th l ngu nhin trn ng ta khng kim tra.

Cu hi 1.17: Kim th hp en l g? Nu cc c trng ca n?


- Khi nim:
Kim th hp en (Black-box Testing): L hnh thc kim th m kim th vin khng cn bit n
cch thc hot ng, m ngun, x l d liu bn trong mt thnh phn/h thng. Cng vic cn lm
l nhp d liu u vo (input) v kim tra kt qu tr v c ng nh mong mun hay khng.
Kim th hp en l phng php kim th yu cu chc nng tp trung vo cc yu cu chc nng
ca phn mm.

6
- c trng:
+ Nhm thuyt minh cc chc nng phn mm v vn hnh ng
+ Thc hin cc php th qua giao din
+ C s: c t, cc iu kin vo/ra v cu trc d liu
+ t ch ti cu trc logic ni ti ca n
- i tng: Modul, h con, ton h thng.

Cu hi 1.18: C nhng loi cng c t ng no tr gip kim th, m t


ni dung ca mi loi?
Cng c kim th t ng - Testing Tools c chia thnh nhng nhm chnh l : Design,
GUI(Graphical User Interface), Load and Performance, Management, Implementation,
Evaluation (S nh gi), Static Analysis (Phn tch tnh) v ngoi ra cn c : Defect Tracking,
Websites v Miscellaneous(Hn Hp).
Test Design Tools
Cc cng c ny gip bn quyt nh test cn g c thc thi. Kim th d liu v
kim th trng hp (Test data and test case) sinh ra(generators).
Test design tools gip to cc Test case, hoc s u vo test ti thiu (l mt phn ca
test case).
C tng cng khong 15 Tools.
GUI Test Tools
Cc cng c ny t ng thc thi cc kim th (Test) cho products vi giao din ngi
dng Graphic. Cng c t ng kim tra Client/Server, bao gm c load testers .
GUI Testing l qu trinh kim th giao din ngi dng ca ng dng v pht hin cc chc
nng chnh xc ca ng dng.
Load and Performance Tools
- Load testing l qu trnh t nhu cu v h thng hoc thit b v o s phn ng ca n.
Load testing c thc hin xc nh hnh vi ca h thng theo 2 iu kin ti bnh
thng v c mong i. N gip xc nh kh nng hot ng ti a ca ng dng
cng nh bt k vng mc v xc dnh cc yu t gy ra suy thoi.
- Performance testing c thc hin xc nh mt h thng c p ng c yu cu v
n nh trong khi cng vic c th. N cng c th phc v vic kim tra, o lng, xc
minh cht lng cc thuc tnh ca h thng, chng hn nh kh nng m rng, tin cy v
s dng ti nguyn.
Test Management Tools
Test managerment tools c s dng lu tr thng tin qu trnh kim th lm vic nh
th no, k hoch hot ng kim th v bo co tnh hnh hot ng ca m bo cht lng
phn mm.
Test Implementation Tools
Dng c khc gip bn thc hin cc bi kim tra. V d, cng c t ng to ra thi quen i
cn s khai y, cng nh cc cng c m c gng lm cho tht bi r rng hn (my pht in
khng nh, vv)
Test Evaluation Tools
Cng c gip bn nh gi cht lng ca cc bi kim tra ca bn. Cc cng c bo him
m i y.
Static Analysis Tools

7
Cng c phn tch cc chng trnh m khng cn chy chng. S liu cng c ri vo th
loi ny.

Cu hi 1.19: Ai l ngi phi tham gia kim th phn mm? Nu vai tr


v trch nhim ca mi i tng?
Cu hi 1.20: th lung iu khin gm nhng yu t no? th lung
iu khin dng lm g?
Control flow testing: l phng php tip cn kim th m xc nh ng i trong qu trnh thc
thi thng qua mt n v chng trnh v sau khi to ra v thc thi cc test case i c ng
dn .
Vic thc hin lin tip ca cu lnh chng trnh c xem nh l lung kim sot.
Cc cu lnh iu kin lm thay i lung mc nh.
ng thi hnh (Execution path) : l 1 kch bn thi hnh n v phn mm tng ng : danh sch c
th t cc lnh c thi hnh ng vi 1 ln chy c th ca n v phn mm, bt u t im nhp
ca n v phn mm n im kt thc ca n v phn mm.
Mc tiu ca phng php kim th lung iu khin l m bo mi ng thi hnh ca n v
phn mm cn kim th u chy ng. Rt tic trong thc t, cng sc v thi gian t mc
tiu trn y l rt ln, ngay c trn nhng n v phn mm nh.

Cu hi 1.20: th lung d liu gm nhng yu t no? th lung d


liu dng lm g?
nh ngha: th dng d liu ca mt chng trnh/n v chng trnh l mt th c hng
G = <N; E>, vi:
- N l tp cc nh tng ng vi cc cu lnh def hoc c-use ca cc bin c s dng trong
n v chng trnh. th G c hai nh c bit l nh bt u (tng ng vi lnh def
ca cc bin tham s) v nh kt thc n v chng trnh.
- E l tp cc cnh tng ng vi cc cu lnh p-use ca cc bin.
Mt s khi nim:
Def: l cu lnh gn gi tr cho mt bin.
Undef: khai bo bin nhng cha cp gi tr cho n.
Use: l cu lnh s dng mt bin (tnh ton hoc kim tra cc iu kin).
C-use: l cu lnh s dng bin tnh ton gi tr ca mt bin khc .
P-use: l cu lnh s dng bin trong cc biu thc iu kin (cu lnh r nhnh, lp,...) .
L do cn kim th dng d liu:
Cn chc chn bin c gn ng gi tr, tc l chng ta phi xc nh c mt ng i
ca bin t mt im bt u ni n c nh ngha n im m bin c s dng.
Ngay c khi gn ng gi tr cho bin th cc gi tr c sinh ra cha chc chnh xc do
tnh ton hoc cc biu thc iu kin sai (bin c s dng sai).

Cu hi 1.21: Nu cc loi iu kin trong cu trc iu khin v cho v


d? C nhng loi sai no trong iu kin khi kim th?
- iu kin logic ca cu trc iu khin:

8
+ iu kin n: l 1 bin Bool (c th c ton t ph nh): X
+ iu kin n: l biu thc quan h gia 2 biu thc s hc , vi l php so snh: <, , =,
hay
A, B l biu thc s hc
+ iu kin phc hp: cu thnh t hn mt iu kin n nh cc ton t Bool: hoc , v
ph nh, trong Xi l iu kin n, & l ton t Bool.
- Kiu sai trong iu kin logic kim th:
+ Sai bin Bool
+ Sai ton t Bool
+ Sai s hng trong biu thc ton t Bool
+ Sai ton t quan h
+ Sai biu thc s hc.

Cu hi 1.22: Chin lc kim th phn nhnh (Branch) ngha l g? Yu


cu t ra cho kim th phn nhnh l g?
- Kim th phn nhnh l chin lc kim th tng iu kin chng trnh
- Kim th nhnh: Vi mi iu kin kt hp C th cc nhnh "true" v "false" ca C v mi iu
kin n trong C phi c kim th t nht 1 ln.
- Yu cu: Khng ch pht hin sai trong iu kin m m cn pht hin cc sai khc trong
chng trnh.

Cu hi 1.23: Kim th n v l g? Hot ng kim th n v gm


nhng ni dung g? N lin quan n nhng nhn t no?
Kim th n v l tin trnh kim th tp trung kim chng vo n v nh nht ca thit k
phn mm l modul. Kim th n v bao gi cng hng theo hp trng v bc ny c
th c tin hnh song song cho nhiu modul.
Unit Testing l vic kim th mc thp nht (cc phng thc method, hm
function, lp class trong m ngun). Nhm m bo cc thnh phn trn hot ng ng
nh yu cu. Vic kim tra mc ny thng do chnh cc Lp trnh vin (Developer)
thc hin trong qu trnh m ha (coding, implement).
Mt m hnh thng c ng dng vi Unit Testing l Pht trin theo nh hng kim th
(Test-Driven Development). Trong , cc unit test c vit trc da theo yu cu vi kt
qu tr v ban u l sai (false). M ngun s c vit sau v c kim tra t ng bng
cc unit test. Vic pht trin c hon thnh khi tt c cc unit test tr v kt qu ng
(true).
Trong mt s ti liu chuyn v Kim th phn mm nh ISTQB (phin bn 2007), khi
nim Unit Testing c hiu l Component Testing. L do l cc cng vic trn c thc
hin bi Lp trnh vin. Cc ti liu trn phn loi di quan im ca mt Kim th vin.
N kim th cc phn sau:
- Kim th giao din
- Khm nghin cu trc d liu cc b.
- Kim th vi cc iu kin bin.
- Cc ng c lp.
- Cc ng x l sai.
Quan h ca n vi hot ng m ha:
- Kim th n v thng c coi l phn ph thm ca bc m ha.

9
- Sau khi bc m ngun c pht trin, c r sot v kim tra tnh ng n c php th
vic thit k ca kim th n v bt u

Cu hi 1.24: Kim th tch hp l g? Kim th tch hp thc hin khi


no?
- Kim th tch hp l mt k thut c tnh h thng xy dng cu trc chng
trnh ngay khi ang tin hnh kim th pht hin sai lin kt vi giao din. Kim
th tch hp nhm nhn c mt phn hay ton b h thng nh mong i.
- Mc ch: tndungj cc modul kim th n v v xy dng chng trnh sao
cho n m bo tun theo thit k.
Phi kim th tch hp v:
+ D liu c th b mt khi i qua mt giao din
+ Mt moun c th c mt hiu ng bt li v tnh ln cc modul khc
+ Cc chc nng ph khi kt hp li c th khng sinh ra chc nng chnh mong
mun
+ Cc iu khng chnh xc ring r c th b phng i n mc khng chp nhn
c.
+ Cc cu trc d liu ton cc c th l ra cc vn .....

Cu hi 1.25: Ni dung chnh ca kim th h thng?


- H thng da vo my tnh do nhiu bn xy dng, ngi pht trin phn mm ch
l mt.
- Vic kim th h thng d c nguy c " li cho nhau"
- Ngi pht trin phn mm cn on trc cc vn giao din c th ny ra v
- Pht hin cc thit k ng x l sai thng qua kim th tt c cc thng tin n
t cc phn t khc ca h thng
- Tin hnh mt lot kim th m phng cc d liu xu hoc cc sai tim tng khc
ti giao din phn mm.
- Bo co cc kt qu kim th lm chng c phng nga li cho nhau
- Nhng ngi tham gia vo trong vic hoch nh v thit k cc kim th h thng
bo m rng phn mm c kim th y
Vic kim th h thng thc t l mt lot cc bc kim th khc nhau c mc ch
chnh l th y h thng da trn my tnh.

Cu hi 1.26: Khi no nn dng test tools? u/nhc ca vic dng Test


tools?
Chng ta s dng test case cho nhng ca test phc tp, c mt s lng test case ln m con ngi
khng th lm c,
u im ca Automation Testing: N chy thay th testers v khng bit mt, khng c chuyn m
au, khng c chuyn phi dng cht, n qu vt, hay i WC. Chng c th chy lin tc ngy
m, mt khi chy ng c 1 case, th chng ta yn tm rng Script s chy ng nhng g chng
ta yu cu.
Nhc im:
- C qu nhiu test tool v mi test tool th li c cc cch s dng khc nhau v phc v
kim th mt chc nng c th.

10
-

hc vic s dng cc tools ny khng kh, nhng s dng c vo thc t (v s


dng tools y khng ch lm tng nng sut cho i d n, m chng ta ang i hn v
mt ng, Testing Service) th cc bn cn phi s dng chng mt cch chun, theo mt
template no .

Cu hi 1.27: K tn mt vi test tools cho kim th chc nng, hiu nng?


Load Runner, HP Quick Test Pro, Soluium, Apache Jmeter,Xceptance LoadTest ,
SiteBlaster, Load-Intelligence, LoadStorm, BrowserMob, Load Impact , Pylot, AppLoader, fwptt,
Jcrawler, vPerformer,

Cu hi 1.28: Quy trnh kim th phn mm ni chung?

Phn tch yu cu: Kim th thng s bt u ly cc yu cu trong cc giai on ca vng


i pht trin phn mm. Trong giai on thit k, cc Tester lm vic vi cc nh pht trin
xc nh nhng kha cnh ca mt thit k c kim chng v nhng thng s c
kim tra.
Lp k hoch kim th: Chin lc kim th, k hoch kim th, kim th sng to V
c mt k hoch l cn thit v nhiu hot ng s c thc hin trong thi gian kim th.
Kim th pht trin: Cc quy trnh kim th, cc kch bn, Test Case, cc d liu c s
dng trong kim th phn mm.
Kim th thc hin: Da trn cc k hoch, cc vn bn kim th v cc bo co bt k li
no tm thy cho nhm pht trin.
Kim th bo co: Sau khi hon tt kim th, cc Tester to ra cc s liu v bo co cui
cng v n lc kim th ca h v c sn sng pht hnh phn mm hay khng.
Phn tch kt qu kim th hoc phn tch thiu st c thc hin bi i ng pht trin
kt hp vi khch hng a ra quyt nh xem nhng thiu st g cn phi c chuyn
giao, c nh v t b (tc l tm ra c phn mm hot ng chnh xc) hoc gii quyt
sau.
Test li khim khuyt: Khi mt khim khuyt c x l bi i ng pht trin, n phi
c kim tra li bi nhm kim th.
Kim th hi quy: Ngi ta thng xy dng mt chng trnh kim th nh l tp hp ca
cc bi kim tra cho mi tch hp mi, sa cha hoc c nh phn mm, m bo rng
nhng cung cp mi nht khng ph hy bt c iu g v ton b phn mm vn cn hot
ng mt cch chnh xc.

Cu hi 1.29: Test plan l g, gm nhng ni dung g?


Mt k hoch kim th d n phn mm (test plan) l mt ti liu m t cc mc tiu, phm vi,
phng php tip cn, v tp trung vo n lc kim th phn mm. Qu trnh chun b test plan l
mt cch hu ch suy ngh ti nhng n lc cn thit xc nhn kh nng chp nhn mt sn
phm phn mm. Cc ti liu hon thnh s gip mi ngi bn ngoi nhm test hiu c 'ti
sao' v 'nh th no' chp nhn sn phm. N cn phi hon ho dng c nhng khng
hon ho v khng ai bn ngoi nhm test s c n. Sau y l mt s hng mc c th c bao
gm trong mt test plan, ty thuc vo tng d n c th:
* Tiu
* nh ngha version ca phn mm (version release)
* Lu li qu trnh hiu chnh ti liu nh tc gi, ngy cp nht, duyt
* Mc lc
* Mc ch ca ti liu, kin chung
* Mc tiu ca chi ph kim th (test)

11
* Gii thiu tng quan v sn phm
* Danh sch ti liu lin quan nh spec, ti liu thit k, cc k hoch test khc,...
* Cc tiu chun thch hp, cc yu cu hp l
* Ngun gc ca cc s thay i
* Relevant naming conventions and identifier conventions
* Overall software project organization and personnel/contact-info/responsibilties
* Test organization and personnel/contact-info/responsibilities
* Assumptions and dependencies
* Phn tch ri ro ca d n
* Cc vn u tin v tp trung test
* Phm vi v gii hn test
* Test outline - a decomposition of the test approach by test type, feature, functionality, process,
system, module, etc. as applicable
* Outline of data input equivalence classes, boundary value analysis, error classes
* Test environment - hardware, operating systems, other required software, data configurations,
interfaces to other systems
* Test environment validity analysis - differences between the test and production systems and their
impact on test validity.
* Test environment setup and configuration issues
* Software migration processes
* Software CM processes
* Test data setup requirements
* Database setup requirements
* Outline of system-logging/error-logging/other capabilities, and tools such as screen capture
software, that will be used to help describe and report bugs
* Discussion of any specialized software or hardware tools that will be used by testers to help track
the cause or source of bugs
* Test t ng - gii thch v tng quan
* Cc cng c test c s sng, bao gm cc version, bn v li,...v.v
* cc qui trnh bo tr v qun l version ca test script/test code
* Theo di v gii quyt vn - Cc cng c v qui trnh
* Cc thc o v test sn phm c s dng
* Bo co cc yu cu v kh nng giao test
* iu kin u vo v u ra ca phn mm
* Giai on v iu kin test ban u
* iu kin dng test v test li
* S b tr nhn s
* Nhng ngi cn training trc khi tham gia
* Ni test
* Cc t chc test bn ngoi s s dng v mc ch, trch nhim, kh nng hon thnh, ngi lin
h v cc vn hp tc ca h
* Cc vn c quyn thch hp, phn loi, bo mt v bn quyn.
* Cc vn m
* Ph lc - bng ch gii, cc t vit tt, ...v.v.

Cu hi loi 2 im

12

Cu hi 2.1: Ti sao phi kim th phn mm? Mc tiu kim th l g?


Ti sao phi kim th phn mm?
- Kim th phn mm l yu t quyt nh ca SQA v khu in hnh ca r sot c t thit k v
lp m.
[Deutsch] Vic pht trin h thng phn mm bao gm hng lot cc hot ng sn xut, ni nhng
c hi cho vic chen sai lm ca con ngi vo l rt ln. Li c th bt u xut hin ti chnh lc
khi u tin trnh ni cc mc tiu.. c th c xc nh sai hay khng hon chnh, cng nh cc
giai on thit k v pht trin v sau.
- Theo Glen Mayers: Kim th phn mm l qu trnh vn hnh chng trnh tm ra li.
- Vn : Cn vn hnh nh th no hiu sut tm ra li l cao nht? v chi ph (thi gian, cng
sc) l t nht?
L do cn kim th phn mm:
Mun nhn thy phn mm nh l mt phn t ca h thng hot ng (xem sn phm)
Hn ch chi ph phi tr cho cc tht bi do li gy ra sau ny (hiu qu)
C k hoch tt nng cao cht lng cho sut qu trnh pht trin (gii php)
Tm quan trng ca kim th phn mm:
Chi ph ca kim th chim: 40% tng cng sc pht trin 30% tng thi gian pht trin
Vi phn mm nh hng ti sinh mng chi ph c th gp t 3 n 5 ln tng chi ph khc
cng li.
- Kim th tt s gip: Gim chi ph pht trin; Tng tin cy ca sn phm phn mm.
* Mc tiu kim th phn mm:
- Mc tiu trc mt: C gng to ra cc ca kim th ch ra li ca phn mm c xy dng
(tc l "nh " phn mm). Nghe c v mang D gy ra nhng vn v tm l.tnh "ph
hoi"
xy dng.
- Mc tiu cui cng: c mt chng trnh tt, chi ph t
Ngi ta thng c nhng quan nim sai g v kim th phn mm?
- Ngi pht trin khng tham gia kim th
- Phn mm c cng b mt cch rng ri ngi l kim th n mt cch tn nhn
- Ngi kim th ch quan tm khi kim bt u
- Kim th c th chng minh c phn mm khng c khim khuyt
- Php kim th thnh cng l kim th khng tm ra li no
- Ch cn kim th mt ln

Cu hi 2.2: Gii thch s khc nhau gia validation v verification.


Kim th phn mm l mt phn ca hot ng ln hn l "xc minh (Verification) v thm nh
(Validation)"
Verification: "Are we building the product right?"
Validation: "Are we building the right product?"
+ Xc minh: l mt tp hp cc hot ng m bo rng phn mm thc hin ng chc nng
c c t.
+ Thm nh: l mt tp cc hot ng m bo rng phn mm c p ng ng yu cu
ca khch hng.

Cu hi 2.3: Gii thch s khc nhau gia failure, error, v fault.


Li phn mm - Software Error
- L cc phn code sai do li c php, logic hoc li do phn tch, thit k.
- Thng l ch mt li ca con ngi trong qu trnh xy dng phn mm.

13
Sai st - Software Fault
- L cc errors dn ti hot ng khng chnh xc ca phn mm. Khng phi error no cng
gy ra fault.
- L li nm trong m ngun, ti liu ca chng trnh. Loi li ny c nhiu nguyn nhn
nh: do error ca con ngi, do cng ngh phc tp, p lc cng vic, do cc thnh phn ca
h thng tng tc vi nhau, Kim th vin ch yu l bt cc loi li ny.
Hng - Software Failures
- Fault s tr thnh failure khi n c kch hot. Mt s ng chy gy ra failures, mt s
khng
- Dng ch cc li di gc ca h thng. Khi mt h thng khng thc hin c chc
nng cn thit, hoc thc hin chc nng khng c php lm th c gi l fail/failure.
Mt bug c th l nguyn nhn ca nhiu fail khi h thng hot ng.

Cu hi 2.4: im mnh v im yu ca kim th t ng v kim th


bng tay?

Cu hi 2.5: Kim th Beta l ci g? Kim th Alpha l ci g? Nu s


ging v khc nhau c bn gia chng?
Kim th Alpha l vic kim th hot ng chc nng thc t hoc gi lp do ngi
dng/khch hng tim nng hoc mt nhm Tester c lp thc hin ti ni sn xut phn
mm. Kim th Alpha thng c s dng cho phn mm i tr (ng gi sn bn) nh
l mt hnh thc kim th mc chp nhn ni b trc khi phn mm chnh thc i vo giai
on kim th Beta.

14
Kim th phin bn Beta c a ra sau khi kim th Alpha v c th c coi l mt hnh
thc m rng ca kim th mc chp nhn ca ngi dng. Cc phin bn ca phn mm,
gi l phin bn beta, c pht hnh cho mt i tng hn ch bn ngoi ca nhm lp
trnh. Phn mm ny c pht hnh cho nhiu nhm ngi dng kim th nhiu hn na
v n c th m bo sn phm c t thiu st v li. i khi, cc phin bn beta c pht
hnh rng ri tng phm vi phn hi thng tin t mt s lng ti ta ngi dng trong
tng lai.
S khc nhau gia kim th Alpha v Kim th Beta
Kim th Alpha: c bn pht trin tin hnh
+ Phn mm s c dng trong bi cnh "t nhin".
+ Ngi pht trin "nhm qua vai" ngi s dng v bo co cc sai v cc vn s dng
(v th cn gi l kim th sau lng)
+ c tin hnh trong mt mi trng c iu khin (theo k hoch ca ngi pht trin)
+ D liu cho kim th Alpha thng l d liu m phng.
Kim th Beta: c nhiu ngi t hng tin hnh, khng c mt ngi pht trin.
+ p dng trong mi trng thc, khng c s kim sot ca ngi pht trin
+ Khch hng s bo co tt c cc vn (thc hoc tng tng) m h gp trong qu
trnh kim th cho ngi pht trin mt cch nh k.
+ Theo bo co ngi pht trin tin hnh sa i v chun b phn phi bn pht hnh
bn hon thin cho ton b nhng ngi t hng.

Cu hi 2.6: Nu cc bc kim th tch hp t trn xung? u nhc


im ca cch tip cn ny?
Phng php tch hp trn xung: y l mt phng php tch hp tng dn vi vic xy
dng cu trc chng trnh. Cc modul c tch hp bng cch i dn xung theo trt t
iu khin, bt u vi modul iu khin chnh (chng trnh chnh). Cc modul ph thuc
(v ph thuc cui cng) vo modul iu khin chnh s c t hp dn vo trong cu trc
theo hoc chiu su trc hay chiu rng trc
Qu trnh tch hp t trn xung c thc hin theo 5 bc:
1. Modul iu khin chnh c dng nh b li kim th (test driver) v tt c cc modul
ph tr c thay th bi cc cung (stub).
2. Thay th dn tng cung bi modul thc thi tng ng.
3. Sau khi tch hp modul , tin hnh cc kim th tng ng.
4. Sau khi hon thnh tp cc kim th ny th thay mt cung (stub) khc bng modul
thc (ngha l quay li bc 2).
5. C th kim th li (ton b hoc mt phn cc kim th trc) bo m rng khng c
sai mi no c sinh ra.
6. Tip tc lp li t bc 2 cho ti khi ton b cu trc chng trnh c xy dng.
u, nhc im:
+ u: Kim th c chc nng iu khin ch yu sm.
+ Nhc: Cn thit cc cung + Cc kh khn km theo cung.
+ Chin lc ny c v khng phc tp, nhng thc t ny ra cc vn logic: khi x l
mc thp li i hi phi tng xng vi mc cao.
+ Cc cung c thay th cho cc modul mc thp, do khng 1 d liu c ngha no c
th chy ngc ln trong cu trc ca chng trnh. Ngi kim th ng trc 2 la chn:
(1) tr nhiu vic kim th ti khi cung c thay th bng modul thc t, (2) xy dng
cc cung thc hin nhng chc nng gii hn m phng cho modul thc ti, v (3) tch hp
phn mm t y cp bc ln.

15

Cu hi 2.7: Nu cc bc kim th tch hp t di ln? u nhc im


ca cch tip cn ny?

Phng php tch hp di ln: bt u xy dng v kim th vi cc modul nguyn t (tc


l cc modul mc thp nht trong cu trc chng trnh). V cc modul ny c tch hp
t di ln nn vic x l yu cu i vi cc modul ph thuc vo mt mc no bao gi
cng c sn v nhu cu v cung b dp b.

Bt u xy dng v kim th t cc modul nguyn t: vic x l nu c i hi cc modul ph tr


th cc modul thc s sn sng (cung b loi).
c thc hin qua 4 bc:
1. Cc modul mc thp c t hp vo trong cc cm (cluster) thc hin mt chc nng
ph tr c bit (cc cluster gi l cc build)
2. Mt b li (chng trnh iu khin kim th) c vit phi hp u vo v u ra ca
ca kim th.
3. Kim th cm .
4. Tho b cc driver v cc cm c t hp ngc ln trong cu trc chng trnh
u nhc im:
+ u: Thit k ca kim th d v khng cn cung
+ Nhc: lun cha chng trnh nh mt chnh th cho n khi modul cui cng c thm
vo.

Cu hi 2.8: Th no l mt ca kim th tt? ca kim th thnh cng? Li


ch ph ca kim th l g?
Ca kim th tt l ca kim th c xc sut cao trong vic tm ra mt li cha c pht hin.
Mt ca kim th thng li lm l t nht mt li cn cha c pht hin.
Mt ca kim th thng li lm l ra khim khuyt, ng thi mang li cc li ch ph:
+ Thuyt minh rng cc chc nng phn mm tng ng vi c t (xc minh)
+ Yu cu thc thi l ph hp (thm nh)
+ Cung cp thm cc ch s tin cy v ch s v cht lng phn mm ni chung (thm
nh)
"Kim th khng th chng minh c vic khng c khim khuyt, n ch c th chng minh rng
khim khuyt phn mm hin hu"

Cu hi 2.9: Gii thch s khc nhau gia kim th hp trng v kim th


hp en?

Kim th hp en (Black-box Testing): L hnh thc kim th m kim th vin khng cn


bit n cch thc hot ng, m ngun, x l d liu bn trong mt thnh phn/h thng.
Cng vic cn lm l nhp d liu u vo (input) v kim tra kt qu tr v c ng nh
mong mun hay khng.
Kim th hp trng (White-box Testing): L hnh thc kim th m kim th vin bit c
cc cu trc bn trong ca chng trnh (m ngun, x l d liu, ). Vic kim th c
da trn cc phn tch v cu trc bn trong ca thnh phn/h thng.

Cu hi 2.10: Nu chng trnh thnh cng tt c cc b kim th ca


kim th hp en. Liu ta c cn kim th hp trng na khng? Ti sao?

16

Cu hi 2.11: Khi no dng k thut bng quyt nh, kim th bin, kim
th theo cp?
Cu hi 2.12: Khi no dng k thut kim th bin, kim th theo cp, s
chuyn trng?
Cu hi 2.13: cc thnh phn cn c trong test plan?
Xem cu 1.29

Cu hi 2.14: Cc giai on chnh ca 1 tin trnh test?


Unit Test Kim tra mc n v
Mt Unit l mt thnh phn PM nh nht m ta c th kim tra c. Theo nh ngha ny, cc hm
(Function), th tc (Procedure), lp (Class), hoc cc phng thc (Method) u c th c xem l
Unit.
V Unit c chn kim tra thng c kch thc nh v chc nng hot ng n gin, chng ta
khng kh khn g trong vic t chc, kim tra, ghi nhn v phn tch kt qu kim tra. Nu pht
hin li, vic xc nh nguyn nhn v khc phc cng tng i d dng v ch khoanh vng trong
mt n th Unit ang kim tra. Mt nguyn l c kt t thc tin: thi gian tn cho Unit Test s
c n b bng vic tit kim rt nhiu thi gian v chi ph cho vic kim tra v sa li cc mc
kim tra sau .
Unit Test thng do lp trnh vin thc hin. Cng on ny cn c thc hin cng sm cng tt
trong giai on vit code v xuyn sut chu k PTPM. Thng thng, Unit Test i hi kim tra
vin c kin thc v thit k v code ca chng trnh. Mc ch ca Unit Test l bo m thng tin
c x l v xut (khi Unit) l chnh xc, trong mi tng quan vi d liu nhp v chc nng
ca Unit. iu ny thng i hi tt c cc nhnh bn trong Unit u phi c kim tra pht
hin nhnh pht sinh li. Mt nhnh thng l mt chui cc lnh c thc thi trong mt Unit, v
d: chui cc lnh sau iu kin If v nm gia then ... else l mt nhnh. Thc t vic chn la cc
nhnh n gin ha vic kim tra v qut ht Unit i hi phi c k thut, i khi phi dng
thut ton chn la.
Cng nh cc mc kim tra khc, Unit Test cng i hi phi chun b trc cc tnh hung (test
case) hoc kch bn (script), trong ch nh r d liu vo, cc bc thc hin v d liu mong
ch s xut ra. Cc test case v script ny nn c gi li ti s dng.
Integration Test Kim tra tch hp
Integration test kt hp cc thnh phn ca mt ng dng v kim tra nh mt ng dng hon
thnh. Trong khi Unit Test kim tra cc thnh phn v Unit ring l th Intgration Test kt hp chng
li vi nhau v kim tra s giao tip gia chng.
Integration Test c 2 mc tiu chnh:
Pht hin li giao tip xy ra gia cc Unit.

17
Tch hp cc Unit n l thnh cc h thng nh (subsystem) v cui cng l nguyn h thng hon
chnh (system) chun b cho kim tra mc h thng (System Test).
Trong Unit Test, lp trnh vin c gng pht hin li lin quan n chc nng v cu trc ni ti ca
Unit. C mt s php kim tra n gin trn giao tip gia Unit vi cc thnh phn lin quan khc,
tuy nhin mi giao tip lin quan n Unit tht s c kim tra y khi cc Unit tch hp vi
nhau trong khi thc hin Integration Test.
Tr mt s t ngoi l, Integration Test ch nn thc hin trn nhng Unit c kim tra cn thn
trc bng Unit Test, v tt c cc li mc Unit c sa cha. Mt s ngi hiu sai rng
Unit mt khi qua giai on Unit Test vi cc giao tip gi lp th khng cn phi thc hin
Integration Test na. Thc t vic tch hp gia cc Unit dn n nhng tnh hung hon ton khc.
Mt chin lc cn quan tm trong Integration Test l nn tch hp dn tng Unit. Mt Unit ti mt
thi im c tch hp vo mt nhm cc Unit khc tch hp trc v hon tt (passed)
cc t Integration Test trc . Lc ny, ta ch cn kim tra giao tip ca Unit mi thm vo vi
h thng cc Unit tch hp trc , iu ny lm cho s lng kim tra s gim i rt nhiu, sai
st s gim ng k.
C 4 loi kim tra trong Integration Test:
Kim tra cu trc (structure): Tng t White Box Test (kim tra nhm bo m cc thnh phn bn
trong ca mt chng trnh chy ng), ch trng n hot ng ca cc thnh phn cu trc ni ti
ca chng trnh chng hn cc lnh v nhnh bn trong.
Kim tra chc nng (functional): Tng t Black Box Test (kim tra ch ch trng n chc nng
ca chng trnh, khng quan tm n cu trc bn trong), ch kho st chc nng ca chng trnh
theo yu cu k thut.
Kim tra hiu nng (performance): Kim tra vic vn hnh ca h thng.
Kim tra kh nng chu ti (stress): Kim tra cc gii hn ca h thng.
System Test - Kim tra mc h thng
Mc ch System Test l kim tra thit k v ton b h thng (sau khi tch hp) c tha mn yu
cu t ra hay khng.
System Test bt u khi tt c cc b phn ca PM c tch hp thnh cng. Thng thng loi
kim tra ny tn rt nhiu cng sc v thi gian. Trong nhiu trng hp, vic kim tra i hi mt
s thit b ph tr, phn mm hoc phn cng c th, c bit l cc ng dng thi gian thc, h
thng phn b, hoc h thng nhng. mc h thng, ngi kim tra cng tm kim cc li,
nhng trng tm l nh gi v hot ng, thao tc, s tin cy v cc yu cu khc lin quan n
cht lng ca ton h thng.
im khc nhau then cht gia Integration Test v System Test l System Test ch trng cc hnh vi
v li trn ton h thng, cn Integration Test ch trng s giao tip gia cc n th hoc i tng
khi chng lm vic cng nhau. Thng thng ta phi thc hin Unit Test v Integration Test bo
m mi Unit v s tng tc gia chng hot ng chnh xc trc khi thc hin System Test.
Sau khi hon thnh Integration Test, mt h thng PM c hnh thnh cng vi cc thnh phn
c kim tra y . Ti thi im ny, lp trnh vin hoc kim tra vin (tester) bt u kim
tra PM nh mt h thng hon chnh. Vic lp k hoch cho System Test nn bt u t giai on

18
hnh thnh v phn tch cc yu cu. Phn sau ta s ni r hn v mt quy trnh System Test c bn
v in hnh.
System Test kim tra c cc hnh vi chc nng ca phn mm ln cc yu cu v cht lng nh
tin cy, tnh tin li khi s dng, hiu nng v bo mt. Mc kim tra ny c bit thch hp cho vic
pht hin li giao tip vi PM hoc phn cng bn ngoi, chng hn cc li "tc nghn" (deadlock)
hoc chim dng b nh. Sau giai on System Test, PM thng sn sng cho khch hng hoc
ngi dng cui cng kim tra chp nhn (Acceptance Test) hoc dng th (Alpha/Beta Test).
i hi nhiu cng sc, thi gian v tnh chnh xc, khch quan, System Test thng c thc hin
bi mt nhm kim tra vin hon ton c lp vi nhm pht trin d n.
Bn thn System Test li gm nhiu loi kim tra khc nhau (xem hnh 6.2), ph bin nht gm:
Kim tra chc nng (Functional Test): bo m cc hnh vi ca h thng tha mn ng yu cu
thit k.
Kim tra kh nng vn hnh (Performance Test): bo m ti u vic phn b ti nguyn h thng
(v d b nh) nhm t cc ch tiu nh thi gian x l hay p ng cu truy vn...
Kim tra kh nng chu ti (Stress Test hay Load Test): bo m h thng vn hnh ng di p lc
cao (v d nhiu ngi truy xut cng lc). Stress Test tp trung vo cc trng thi ti hn, cc "im
cht", cc tnh hung bt thng...
Kim tra cu hnh (Configuration Test)
Kim tra kh nng bo mt (Security Test): bo m tnh ton vn, bo mt ca d liu v ca h
thng.
Kim tra kh nng phc hi (Recovery Test): bo m h thng c kh nng khi phc trng thi n
nh trc trong tnh hung mt ti nguyn hoc d liu; c bit quan trng i vi cc h thng
giao dch nh ngn hng trc tuyn.
Acceptance Test - Kim tra chp nhn sn phm
Thng thng, sau giai on System Test l Acceptance Test, c khch hng thc hin (hoc y
quyn cho mt nhm th ba thc hin). Mc ch ca Acceptance Test l chng minh PM tha
mn tt c yu cu ca khch hng v khch hng chp nhn sn phm (v tr tin thanh ton hp
ng).
Acceptance Test c ngha ht sc quan trng, mc d trong hu ht mi trng hp, cc php kim
tra ca System Test v Accepatnce Test gn nh tng t, nhng bn cht v cch thc thc hin li
rt khc bit.
i vi nhng sn phm dnh bn rng ri trn th trng cho nhiu ngi s dng, thng thng s
thng qua hai loi kim tra gi l Alpha Test v Beta Test. Vi Alpha Test, ngi s dng (tim
nng) kim tra PM ngay ti ni PTPM, lp trnh vin s ghi nhn cc li hoc phn hi, v ln k
hoch sa cha. Vi Beta Test, PM s c gi ti cho ngi s dng (tim nng) kim tra ngay
trong mi trng thc, li hoc phn hi cng s gi ngc li cho lp trnh vin sa cha.
Regression Test - Kim tra hi quy
Trc tin cn khng nh Regression Test khng phi l mt mc kim tra, nh cc mc khc
ni trn. N n thun kim tra li PM sau khi c mt s thay i xy ra, bo m phin bn

19
PM mi thc hin tt cc chc nng nh phin bn c v s thay i khng gy ra li mi trn
nhng chc nng vn lm vic tt. Regression test c th thc hin ti mi mc kim tra.
V d: mt PM ang pht trin khi kim tra cho thy n chy tt cc chc nng A, B v C. Khi c
thay i code ca chc nng C, nu ch kim tra chc nng C th cha , cn phi kim tra li tt c
cc chc nng khc lin quan n chc nng C, trong v d ny l A v B. L do l khi C thay i,
n c th s lm A v B khng cn lm vic ng na.
Mc d khng l mt mc kim tra, thc t li cho thy Regression Test l mt trong nhng loi
kim tra tn nhiu thi gian v cng sc nht. Tuy th, vic b qua Regression Test l "khng c
php" v c th dn n tnh trng pht sinh hoc ti xut hin nhng li nghim trng, mc d ta
"tng rng" nhng li hoc khng c hoc c kim tra v sa cha ri!

Bi tp
Cu hi 2.15: Cho Form gm 1 ratio button N, 1 ratio button c thn v
1 Danh sch chn Chuyn ngnh gm: CNTT, QTKD, VT, K ton.
a. Nu kim th tt c cc trng hp xy ra th cn bao nhiu test cases,
b. Mi test case cha bao nhiu cp gi tr?
c. Lit k cc cp gi tr c th xy ra?
d. Thit k b pairwise test suite (kim th theo cp)

Cu hi 2.16: Mt phn mm iu khin chi game n gin gia 2 ngi


chi. Mi ngi iu khin mt nt bm a bng vo l. Mi ln bng
vo l, ngi c cng 1 im. Ai c 5 im trc s thng. Nu
bng khng vo l, ngi cn li c quyn iu khin bng.
a. Lp s chuyn trng thi
b. Xc nh cc ng chy ph ht cc cnh
c. Thit k test case tng ng

Cu hi 2.17: Thng tin v block1 bao gm size(small, large), color(red,


green, blue), shape (circle, triangle, square).
a. Nu kim th tt c cc trng hp xy ra th cn bao nhiu ca kim th?
b. S cp ti a m mt ca kim th c th cha
c. Xc nh cc cp gi tr c th xy ra
d. Thit k b kim th theo cp (pairwise test suite)
di.

20

Cu hi 2.18: Cn pht trin module kim tra iu kin d thi ca sinh


vin gm:
Nu sinh vin i hc >=80% s bui, im gia k >0, im bi tp ln >0
s c thi.
Nu sinh vin iu kin d thi v c im bi tp ln = 10 hoc im
gia k = 10 s c min thi.
a. Dng k thut bng quyt nh xc nh test cases
b. Dng k thut th nguyn nhn kt qu xc nh test cases

Cu hi 2.19: Cho h thng S nhn n tham s u vo, mi tham s c m


gi tr. Tr li cu hi:
a. S cp ti a m mt ca kim th cha ti a bao nhiu cp
b. Trong trng hp l tng, ta cn bao nhiu ca kim th bao ph tt c cc cp ca h
thng?
c. Tnh tng s cp m b kim th phi bao ph?
d. Cho n = 13, m = 3. S ca kim th ti thiu cn chn thu c b kim th theo cp
(pairwise test suite)?

Cu hi 2.20: Form ng k mua v tu c cho nh hnh v. Danh sch


ga Ga i v Ga n l {H Ni, Vinh, Hu, Nng, Si Gn}. Danh sch
mc tu l {SE,TN}. Khng tnh trng Ngy i, hy thc hin:

a. Nu kim th tt c cc trng hp xy ra th cn bao nhiu ca kim th?


b. S cp ti a m mt ca kim th c th cha
c. Xc nh cc cp gi tr c th xy ra
d. Thit k b kim th theo cp (pairwise test suite)

Cu hi 2.21: Xt tab ty chn View t mt phin bn ca phn mm


Powerpoint Microsoft. Bng (c) chnh l d liu sau trch xut.
a. Nu kim th tt c cc trng hp xy ra th cn bao nhiu ca kim th?
b. S cp ti a m mt ca kim th c th cha
c. Xc nh cc cp gi tr c th xy ra
d. Thit k b kim th theo cp (pairwises test suite)

21

Cu hi 2.22: Cn pht trin module tnh thu thu nhp c nhn da trn
phn thu nhp tnh thu. Biu thu thu nhp c nhn c cho nh bng
di:
Bc thu
1
2
3
4
5
6
7

Phn thu nhp


tnh thu/nm
(triu ng)
n 60
Trn 60 n 120
Trn 120 n 216
Trn 216 n 384
Trn 384 n 624
Trn 624 n 960
Trn 960

Phn thu nhp


tnh thu/thng
(triu ng)
n 5
Trn 5 n 10
Trn 10 n 18
Trn 18 n 32
Trn 32 n 52
Trn 52 n 80
Trn 80

Thu sut (%)


5
10
15
20
25
30
35

(a) Thit k cc ca kim th dng k thut phn tch gi tr bin


(b) Thit k cc ca kim th dng k thut phn vng tng ng

22

Cu hi 2.23: Li sut tin gi theo nm ca khch hng c nhn ti ngn


hng X c cho bng di. Li c tnh trn s ngy thc t.
K hn
Tit kim
Khng k hn
7 ngy
14 ngy
1 thng
2 thng
3 thng
6 thng
9 thng
12 thng
24 thng

VND

EUR

USD

1.20 %
1.20 %
1.20 %
5.00 %
6.50 %
6.80 %
7.00 %
7.00 %
7.50 %
8.00 %

0.01 %

0.10 %

0.10 %
0.10 %
0.20 %
0.30 %
0.40 %
0.50 %
0.80 %

1.20 %
1.20 %
1.20 %
1.20 %
1.20 %
1.20 %
1.20 %

(a) Thit k cc ca kim th dng k thut phn tch gi tr bin


(b) Thit k cc ca kim th dng k thut phn vng tng ng

Cu hi 2.24: Mt chng trnh phn loi tam gic c vo cc gi tr s


nguyn trong khong [0,100]. 3 gi tr A, B, v C c dng biu din
di 3 cnh tam gic. Chng trnh in ra thng bo 3 gi tr ny c phi
l 3 cnh tam gic khng.
(a) Thit k cc ca kim th dng k thut phn tch gi tr bin
(b) Thit k cc ca kim th dng k thut phn vng tng ng

Cu hi 2.25: Mt chng trnh phn loi tam gic c vo cc gi tr s


nguyn trong khong [0,100]. 3 gi tr A, B, v C c dng biu din
di 3 cnh tam gic. Chng trnh in ra thng bo 3 gi tr ny c phi
l 3 cnh tam gic cn khng.
(a) Thit k cc ca kim th dng k thut phn tch gi tr bin
(b) Thit k cc ca kim th dng k thut phn vng tng ng

Cu hi 2.26: Mt chng trnh phn loi tam gic c vo cc gi tr s


nguyn trong khong [0,100]. 3 gi tr A, B, v C c dng biu din
di 3 cnh tam gic. Chng trnh in ra thng bo 3 gi tr ny c phi
l 3 cnh tam gic u khng.
(a) Thit k cc ca kim th dng k thut phn tch gi tr bin
(b) Thit k cc ca kim th dng k thut phn vng tng ng

23

Cu hi 2.27: Mt chng trnh phn loi tam gic c vo cc gi tr s


nguyn trong khong [0,100]. 3 gi tr A, B, v C c dng biu din
di 3 cnh tam gic. Chng trnh in ra thng bo 3 gi tr ny c phi
l 3 cnh tam gic vung khng.
(a) Thit k cc ca kim th dng k thut phn tch gi tr bin
(b) Thit k cc ca kim th dng k thut phn vng tng ng

Cu hi loi 3 im
Cu hi 3.1: Cho hm tm kim nh phn vit bng C. input array v
c sp xp theo gi tr tng dn, n l kch thc mng, ta cn tm ch s
mng ca phn t x. Nu khng tm thy x trong mng, tr v gi tr -1.
int binSearch(int x, int v[], int n){
int low, high, mid;
low = 0;
high = n - 1;
while (low<=high){
mid = (low + high)/2;
if (x<v[mid])
high = mid - 1;
else if (x > v[mid])
low = mid + 1;
else
return mid;
}
return -1;
}
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b cu lnh
c. B xung thm ng (nu cn) bao ph ht cc ng r (branch)
d. Vi mi ng xc nh trn, tm biu thc tin t tng ng
e. Gii biu thc tin t trn sinh ra cc u vo ca kim th v sau c lng u ra
tng ng
f. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng
kh thi.

Cu hi 3.2: Gi m bn di tnh tng cc phn t >0 ca mng a


sum_of_all_positive_numbers(a, num_of_entries, sum)

24

sum =0;
init = 1;
while(init <= num_of_entries)
if a[init] > 0
sum = sum + a[init]
endif
init = init + 1
endwhile
end sum_of_all_positive_numbers
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b cu lnh
c. B xung thm ng (nu cn) bao ph ht cc ng r (branch)
d. Vi mi ng xc nh trn, tm biu thc tin t tng ng
e. Gii biu thc tin t trn sinh ra u vo cc ca kim th v sau c lng u ra
tng ng
f. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng
kh thi.

Cu hi 3.3: Hm bn di tr v ch s phn t cui cng trong x c gi


tr bng y. Nu khng tn ti, tr v gi tr -1.
int findLast(int[] x, int y){
for (int i = x.length -1; i > 0; i--){
if (x[i] == y)
return i;
}
return -1;
}
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b cu lnh
c. B xung thm ng (nu cn) bao ph ht cc ng r (branch)
d. Vi mi ng xc nh trn, tm biu thc tin t tng ng
e. Gii biu thc tin t trn sinh ra u vo cc ca kim th v sau c lng u ra
tng ng
f. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng
kh thi.

Cu hi 3.4: Hm bn di tr v ch s phn t cui cng trong x c gi


tr bng 0. Nu khng tn ti, tr v gi tr -1.
int lastZero(int[] x){

25

for (int i = 0; i < x.length; i++){


if (x[i] == 0)
return i;
}
return -1;
}
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b cu lnh
c. B xung thm ng (nu cn) bao ph ht cc ng r (branch)
d. Vi mi ng xc nh trn, tm biu thc tin t tng ng
e. Gii biu thc tin t trn sinh ra u vo cc ca kim th v sau c lng u ra
tng ng
f. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng
kh thi.

Cu hi 3.5: Hm bn di tr v s phn t l s >0.


int countPositive(int[] x){
int count = 0;
for (int i = 0 ; i < x.length; i++){
if (x[i] >=0)
count++;
}
return count;
}
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b cu lnh
c. B xung thm ng (nu cn) bao ph ht cc ng r (branch)
d. Vi mi ng xc nh trn, tm biu thc tin t tng ng
e. Gii biu thc tin t trn sinh ra u vo cc ca kim th v sau c lng u ra
tng ng
f. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng
kh thi.

Cu hi 3.6: Cho on code


public static void f1 (int x, int y) {
if (x < y) { f2 (y); }
else { f3 (y); };
}
public static void f2 (int a) {
if (a % 2 == 0) {
f3 (2*a);

26

};
}
public static void f3 (int b) {
if (b > 0) { f4(); }
else { f5(); };
}
public static void f4()
{... f6()....}
public static void f5()
{... f6()....}
public static void f6()
{...}
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b cu lnh
c. B xung thm ng (nu cn) bao ph ht cc ng r (branch)
d. Vi mi ng xc nh trn, tm biu thc tin t tng ng
e. Gii biu thc tin t trn sinh ra u vo cc ca kim th v sau c lng u ra
tng ng
f. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng
kh thi.

Cu hi 3.7: Cho hm tm kim nh phn vit bng C. Input array v


c sp xp theo gi tr tng dn, n l kch thc mng, ta cn tm ch s
mng ca phn t x. Nu khng tm thy x trong mng, tr v gi tr -1.
int binSearch(int x, int v[], int n){
int low, high, mid;
low = 0;
high = n - 1;
while (low<=high){
mid = (low + high)/2;
if (x<v[mid])
high = mid - 1;
else if (x > v[mid])
low = mid + 1;
else
return mid;
}
return -1;
}
Cho u vo cc ca kim th di y:
t1= (x=1, v={1,2,5,7,9},n=5)
t2= (x=3, v={1,3,9},n=3)

27

t3= (x=9, v={1,2,5,7,9},n=5)


t4= (x=4, v={1,2,5,7,9},n=5)
t5= (x=10, v={1,2,5,7,9},n=5)
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo trn
c. Tm tp u vo ca kim th nh nht bao ph ht cu lnh
d. Tm tp u vo ca kim th nh nht bao ph ht ng r
e. Tm tp u vo ca kim th nh nht bao ph ht ng vi n = 4
f. Liu tt c cc ng tng ng e c kh thi hay khng? Nu khng ch ra nhng ng
khng kh thi.

Cu hi 3.8: Gi m bn di tnh tng cc s dng ca mng a


sum_of_all_positive_numbers(a, num_of_entries, sum)
sum =0;
init = 1;
while(init < num_of_entries)
if a[init] > 0
sum = sum + a[init]
endif
init = init + 1
endwhile
end sum_of_all_positive_numbers
Cho u vo ca kim th di y:
t1= (a={0,2,-5,7,-9}, num_of_entries=5)
t2= (a={1,-3,9}, num_of_entries=3)
t3= (a={1,-2,5,7,0}, num_of_entries=5)
t4= (a={-1,2,0,7,-9}, num_of_entries=5)
t5= (a={1,-2,5,7,9}, num_of_entries=5)
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo ca kim th
c. Tm tp u vo ca kim th nh nht bao ph ht cu lnh
d. Tm tp u vo ca kim th nh nht bao ph ht ng r
e. Tm tp u vo ca kim th nh nht bao ph ht ng vi num_of_entries = 4
f. Liu tt c cc ng tng ng e c kh thi hay khng? Nu khng ch ra nhng
ng khng kh thi.

Cu hi 3.9: Hm di y tnh s ngy gia 2 ngy/thng cho trc trong


cng 1 nm. Bit 1<=month1, month2<=12
1<=day1,day2<=31;
1<=year<=10000

28

public static int cal (int month1, int day1, int month2, int day2, int year) {
int numDays;
if (month2 == month1)
numDays = day2 - day1;
else {
// bo qua thang thu 0.
int daysIn[] = {0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// kiem tra nam nhuan
int m4 = year % 4;
int m100 = year % 100;
int m400 = year % 400;
if ((m4 != 0) || ((m100 ==0) && (m400 != 0)))
daysIn[2] = 28;
else
daysIn[2] = 29;
// bt u tnh t ngy
numDays = day2 + (daysIn[month1] - day1);
//cng thm s ngy khong gia cc thng
for (int i = month1 + 1; i <= month2-1; i++)
numDays = daysIn[i] + numDays;
}
return (numDays);
}
Cho u vo ca kim th di y:
t1= (12,20,12,30,2013)
t2= (2,10,11,1,2013)
t3= (1,1,12,1,2004)
t4= (2,20,3,1,2004)
t5= (2,20,3,1,1900}
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo ca kim th
c. Tm tp u vo ca kim th nh nht bao ph ht cu lnh
d. Tm tp u vo ca kim th nh nht bao ph ht ng r
e. Tm tp u vo ca kim th nh nht bao ph ht ng vi month1 = 2
f. Liu tt c cc ng tng ng e c kh thi hay khng? Nu khng ch ra nhng
ng khng kh thi.

Cu hi 3.10: Hm bn di tr v ch s phn t cui cng trong x c gi


tr bng y. Nu khng tn ti, tr v gi tr -1.
int findLast(int[] x, int y){
for (int i = x.length -1; i > 0; i--){
if (x[i] == y)
return i;

29

}
return -1;
}
Cho u vo ca kim th di y:
t1= (x={5}, y=5)
t2= (x={1,-3,5}, y=5)
t3= (x={5,-2,5,7,0}, y=5)
t4= (x={-1,2,0,5,-9}, y=5)
t5= (x={1,-2,3,7,9}, y=5)
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo ca kim th
c. Tm tp u vo ca kim th nh nht bao ph ht cu lnh
d. Tm tp u vo ca kim th nh nht bao ph ht ng r
e. Tm tp u vo ca kim th nh nht bao ph ht ng vi s phn t ca mng x =
4
f. Liu tt c cc ng tng ng e c kh thi hay khng? Nu khng ch ra nhng
ng khng kh thi.

Cu hi 3.11: Hm bn di tr v ch s phn t cui cng trong x c gi


tr bng 0. Nu khng tn ti, tr v gi tr -1.
int lastZero(int[] x){
for (int i = 0; i < x.length; i++){
if (x[i] == 0)
return i;
}
return -1;
}
Cho u vo ca kim th di y:
t1= (x={5})
t2= (x={0})
t3= (x={5,-2,5,7,0})
t4= (x={-1,2,0,5,-9})
t5= (x={0,-2,3,7,9})
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo ca kim th
c. Tm tp u vo ca kim th nh nht bao ph ht cu lnh
d. Tm tp u vo ca kim th nh nht bao ph ht ng r
e. Tm tp u vo ca kim th nh nht bao ph ht ng vi s phn t ca mng x =
4
f. Liu tt c cc ng tng ng e c kh thi hay khng? Nu khng ch ra nhng
ng khng kh thi.

30

Cu hi 3.12: Hm bn di tr v s phn t l s >0.


int countPositive(int[] x){
int count = 0;
for (int i = 0 ; i < x.length; i++){
if (x[i] >=0)
count++;
}
return count;
}
Cho u vo ca kim th di y:
t1= (x={5})
t2= (x={0})
t3= (x={5,-2,5,7,0})
t4= (x={-1,2,0,5,-9})
t5= (x={0,-2,3,7,9})
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo ca kim th
c. Tm tp u vo ca kim th nh nht bao ph ht cu lnh
d. Tm tp u vo ca kim th nh nht bao ph ht ng r
e. Tm tp u vo ca kim th nh nht bao ph ht ng vi s phn t ca mng x =
4
f. Liu tt c cc ng tng ng e c kh thi hay khng? Nu khng ch ra nhng
ng khng kh thi.

Cu hi 3.13: Phng thc printPrimes bn di tm v in ra n s nguyn


t.
private static void printPrimes (int n)
{
int curPrime;
int numPrimes;
boolean isPrime;
int [] primes = new int [MAXPRIMES];
primes [0] = 2;
numPrimes = 1;
curPrime = 2;
while (numPrimes < n)
{
curPrime++;
isPrime = true;
for (int i = 0; i <= numPrimes-1; i++)
{
if (isDivisible (primes[i], curPrime))
{

31

isPrime = false;
break;
}
}
if (isPrime)
{
primes[numPrimes] = curPrime;
numPrimes++;
}
}
for (int i = 0; i <= numPrimes-1; i++)
{
System.out.println ("Prime: " + primes[i]);
}
}
Cho u vo ca kim th di y:
t1= (n=0)
t2= (n=1)
t3= (n=2)
t4= (n=3)
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo ca kim th
c. Tm tp u vo ca kim th nh nht bao ph ht cu lnh
d. Tm tp u vo ca kim th nh nht bao ph ht ng r

Cu hi 3.14: Cho on code


public static void f1 (int x, int y) {
if (x < y) { f2 (y); }
else { f3 (y); };
}
public static void f2 (int a) {
if (a % 2 == 0) {
f3 (2*a);
};
}
public static void f3 (int b) {
if (b > 0) { f4(); }
else { f5(); };
}
public static void f4()
{... f6()....}
public static void f5()
{... f6()....}

32

public static void f6()


{...}
S dng u vo ca kim th di y:
t1= f1(0, 0)
t2= f1(1, 1)
t3= f1(0, 1)
t4= f1(3, 2)
t5= f1(3, 4)
a. V th lung iu khin
b. Ch ra ng trn th lung iu khin tng ng vi mi u vo ca kim th
c. Tm tp u vo ca kim th nh nht bao ph ht nt
d. Tm tp u vo ca kim th nh nht bao ph ht cnh
e. Tm tp u vo ca kim th nh nht bao ph ht ng

Cu hi 3.15: public void foo2(int a, int b, int x) {


if (a>1 && b==0) {
x=x/a;
}
for ( int i = 1; i < 3; i++){
if true x=x+1;
}
}
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b ng r (branch)
c. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng
kh thi.
d. Xc nh test case tng ng vi cc ng kh thi

Cu hi 3.16:
sum(a, numEntry,sum){
sum = 0;
for (init =1; init <=numEntry;init++)
if (a[init]>0)
sum = sum + a[init];
if (false)
sum = 0;
}
a. V th lung iu khin
b. T th lung iu khin, xc nh tp cc ng t u vo ti u ra bao ph c
ton b ng r (branch)

33

c. Liu tt c cc ng trn c kh thi hay khng? Nu khng ch ra nhng ng khng


kh thi.
d. Xc nh test case tng ng vi cc ng kh thi

Cu hi 3.17: Cho s gi cc module nh sau


A

(cn thiu)

a. Xc nh th t tch hp v cc stub/driver (nu cn) khi dng k thut topdown


b. Xc nh th t tch hp v cc stub/driver (nu cn) khi dng k thut bottom up
c. Xc nh th t tch hp v cc stub/driver (nu cn) khi dng k thut sandwich

Cu hi 3.18: Cho code


1.
2.
3.
4.
5.
6.
7.

int modifiedbinsearch(int X, int V[], int n){


int low, high, mid;
low = 0;
high = n - 1;
while (low <= high) {
mid = (low + high)/2;
if (X < V[mid]) {
8. high = mid - 1;
9. mid = mid - 1; }
10. else if (X > V[mid])
a. low = mid + 1;
b. else
c. return mid;
d. }
11. return -1; }
a. V th lung d liu.
b. Xc nh im bt thng (anomaly) ca code trn
c. Gi s mng V[] c t nht 1 phn t, xc nh ng khng kh thi.

34

Cu hi 3.19: Chng trnh SquaresLoopRange(start-number, stopnumber) hin th bnh phng ca 1 dy s t start-number ti stopnumber. Nu start-number ln hn stop-number error message cn c
hin th: Start-limit greater than stop-limit! Sq
a. Vit chng trnh
b. Thit k test cases
c. Vit code JUnit tng ng

Cu hi 3.20: Vit chng trnh MultiplesLoopRange(start-number, stopnumber, num) hin th dy s trong khong [start-number, stop-number] v
dy s phi l bi s ca num.
Nu start-number ln hn stop-number, chng trnh s hin th dy gim
dn.
a. Vit chng trnh
b. Thit k test cases
c. Vit code JUnit tng ng

Cu hi 3.21:
H thng ghi li nht k nhit theo thi gian. Nhng output mt
format ring, bao gm mt dy cc symbols, u tin l 1 s biu din
nhit bt u, k hiu tip biu din s thay i nhit so vi trc
. Cc symbols c gii m nh sau:

'.' khng thay i

'+' tng 1 so vi trc n

'-' gim 1 so vi trc n


Cc gi tr c bin dch thnh cc s kiu int.
Ta cn tnh median ca d liu nhit . u tin, ta cn sp xp. Sau :
Nu mng cha s l phn t n, median l phn t chnh gia:phn t th (n+1)/2.
Nu mng cha s chn phn t, median l gi tr trung bnh ca 2 phn t th n/2v
(n/2)+1.
Lu : nhit l integer, nhng gi tr median l float.
a. Vit chng trnh TempMedian
b. Thit k test cases
c. Vit code JUnit tng ng

35

Cu hi 3.22:
DNA c to bi 2 DNA-Strands (chui), chng xon vi nhau to thnh 1
double helix.
Mi chui DNA l chui cc bases. Gm 4 bases:
adenine (abbreviated A)
cytosine (C)
guanine (G)
thymine (T)
Bases c cp: A bt cp vi T, C bt cp vi G. V d, mt si l A-C-G-G-T-C
Si cn li s l : T-G-C-C-A-G
V ta c cc cp A:T, C:G, G:C, G:C, T:A v C:G. Cch lu tr thng tin nh vy l d tha,
nhng ta c th phn i 1 double helix v b 1 pha i, ta vn c th ti to li n. Ngoi ra,
nu l mun nhn i double helix, ta c th chia thnh 2 chui, ti to li mi pha v s thu
c 2 bn copy t bn gc.
Ta cn to 1 class biu din 1 chui DNA. API cho class DNAStrand:
public DNAStrand(String dna): khi to
public boolean isValidDNA(): Tr v true nu DNA l valid, ngha l ch c cc k t hoa A,
T, C, G v cha t nht 1 k t.
public String complementWC(): Tr v Watson Crick complement, l chui DNA b si
cn li trong double helix. Thay T bng A, A bng T, C bng G v G bng C.
public String palindromeWC(): Tr v Watson Crick Palindrome, chui o ca chui DNA
b.
public boolean containsSequence(String seq): Tr v true nu DNA cha chui con seq.
public String toString(): Tr v string DNA.
a. Vit chng trnh TempMedian
b. Thit k test cases
c. Vit code JUnit tng ng

Ghi ch: K hiu (m) cu hi c quy nh X.Y


Trong : + X tng ng vi s im cu hi (X chy t 1 n 5)
+ Y l cu hi th Y (Y chy t 1 tr i)

36