Aoop 2
Aoop 2
aVa
stualons wheve endlre
CXample o a Situatlon uwhere TpD ull not wov (Huvde Thnk of
pr cduchor code is Peajulved before shurling 1 festiry phase)
Sol
When Not fo Se TDD
est-driven clevelopmerI is rot occeptan ce tegtirq: You are foly twall piecea ol ode, bd nd
e eneal applicadhao behuviov. for to, yeu Can rely on audorvole d bo lg auch as Cicumber
Ov oryVO. Acceptane lestiwq an be inkgraded wfh cdogst c TDD, and rt on erve as an
3 Yau ave doirg 9PTkE ding When you're just deslig a new AD er tryy o ncs integration
al a tes-of- proh masp e iH's not the fime fo do TDD p t in Tat phase, pu're trydrg
ditferend arql es n d malke mustake ore nadutol, alter kn0 w'ihe clear rejureners and
inderloce, Phon TDD a0 help move
Vieud tegtirg :Creativ a vicual Teature can be verq arti ve and intudive Coork moybe you
oa
don't krou te inlefoce until it dene AlHey Hrishrg t, pu Con fhinlk obot hauw fe taf n
utome, u tyi to fet iH fhe con bek yoe Cresive mindeet .
fradHlo nal tegBirg bcuseg on te deseung of feg Cases, an d also N te fegf will eeate
So impotan
Should hove a peeMic ptrmom e We shbuld be auuare of
SIn cqale modelling,the tegtvg
uhy ae are festirg and te leyel of he feshirg
In-Lob
4- Write a Jova Pregrom 1or caleulator by pa SS i nq al fest cases
: pockoqe source
pubue closS Coleulator
im ex pected ResuH 80
int AcfuoRealh= myCalculatov Add (10,20);
Agsevt asert Eayuals (he Sum of two pasHve numbers Cerre ct" expected Resu l
ActuolResat );
Tesf
pubic void oddTooegutive ANurnbers ()
nt eupecledResuat3o
ind AclualResul- myaleulator.Add (-10, -20);
Agsert acSert toyuals (*The um of fwo hegative humbexsis corr ecd " e peefed Reaah
AectalResu H);
pachage Courte
publuic class altubtor
pubkc ivd Ad d vt number 1, int number 2)
eturn 0
3
Pockage Sourte
puble clasS Caloulator f
publed
Pubke Add ird rumber1, int number
reurnDum ber 1f humber 2)
A code hat
Sinple Scerariai As a developer wnt fo Implement so
prins te numbers
rom to too .
Gaiven an Inpu of numbers frem 1 to6
ohen
A numbev S a
Multide o3 uyo"Fzz"
A Numbey is o1 5 yedurn Bu Zz'
A number ic Ootfooth 3 and 's' retun "
Fizz Butz"
A rumber is not dvisible b3 or Fse lf.
s return he numbe
Then Pint "Fizz", "Buzz", "Fizz Buzz" or he number acordirqy.
Expeded odpuh 1, 2, tizz, 4, Bu22, IL4, Fi2z Bu2z, 16,
Sol. pachage p
importjava util Scanner;
pubuc class fizz Buzz
Hest-muHipleof 3();
f Ccoant S-= o)
test. mutti ple otaC);
3
Sypbern-oud printnnunf
fFizzbuzz (idx),
F. fauzz (idp);
hazbez Gx)
scclasec);
o acept e pacsuaoy d
when Te krgfh of H
Developmendt progfa
Driven
3. Wvwife a Test vlidador)
s fo 1o darocters
("Pa.sutv d
sheuld be bekoeen
Jnpu
flb cl23
Output:
uer d :acep ted
olid pa
Sol pachage Prac
teirg.Ast dt;
impet org. ferdrg.anndotions, "es
impov+ ovq-
aublic clas TestPasseuDrd
{
Tegd
publc veid
Test Passuerd
O
pubbic ed Test Pacsubvd levgth
pockag praPassaerd
C; aledodbyf
clais
pubke
pubhc peckean lalid (siniy Passuwbvd
H(pacs
uow d. Ength0) >- 5 £2 Phasuoer d. Ergth )e~ to)
return rue
elte
relarn alse
Post Lab:
N I a java prooram to heck uhether R glven number is odd or even an d do un it fery
inJUnit
Sol pubuc claus vena Oddf
publkc sfadic Gir eyen or odd Gnt number )
retu number 2 =
o? 'ven :
"
odd'
2. Wvite a JUht test asauming you have too shingkuffer referen Ces name d gbone and s6Tua
0vd u n t o pols N he tuo releven ces
you
point To 1ke Same ShirgBuler ebfel
pubhc boslcon) Striny BuPH_ (sthing Butter, skont, Sting Buter sbTuwo) f
Sblwo Sbohe
(sblwb -c bohe )
return fvue
else
rearo ale
package Strivg Butter JUnt;