Note of testing and test-cases

looneyvillestaticΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 4 χρόνια και 4 μήνες)

307 εμφανίσεις

nov
-
2011 Peter Levinsky

Test


Background:

Larman ch.
21

p.
385
-
389

UPEDU (
www.upedu.org
) the test disciplines
see testing


Types (or
Stages
)

of Testing



Developer Testing

o

Normal testing by the developer / programmer


to see it do work



Independent and Stakeholder Testing

o

Independent Testing denotes the test design and implementation that it is most
appropriate for someone independent from the team of developers to do.



Unit
Tests

o

Systematic automatic test of a unit (testing from a black box view)



Integration Test

o

integration testing is performed to ensure that the components
in combination do
work (e.g. that classes across packages do work)



System Test

o

S
ystem testing is do
ne when the software is functioning as a whole.
Do the whole
system works



Acceptance Test

o

The users do the testing and accepting as a
final test action prior to deploying the
software.
Check that all use
-
cases and all non
-
functional requirements work


Unit testing

See the artifact test case


http://www.upedu.org/process/artifact/ar_tstcs.htm


Especially you can see the guidelines of test case
http://www.upedu.org/process/gdlines/md_tstcs.htm


From the guidelines

You can see how to set up (or derive) test cases o test your
use
-
cases

as well as the
supplementary
requirements

and for

unit test

and for
Acceptance test

Below
is the Unit testing discussed. When talking of unit test you can divide them into

White box testing



where you check all programming lines have been executed with an accepted
result

Black box testing



where you c
heck all methods have been executed and all parameter boundaries
have been checked


of cause again with an accepted result

nov
-
2011 Peter Levinsky

From
Upedu

you can read in more detail how to construct (derive) different test cases.

Here is an example

of the black box testing


which is the most common
:

We have the class
Book




The title must be not null and not empty.



The Author must be not null and not empt
y.



The isbn must be not null and the length must be greater than 9



copyId must be in the range 1
-
15

We have to set up all ‘possible’ input values

(normal values, values on the boundary, values outside boundary and illegal values)

Test
case
#

Description o
f test case

Expected value

Passed
succesfully

1

Default constructor

Object created


2

setTitle


p慲慭整敲enu汬

䥬汥l慬a牧um敮瑅硣xp瑩on


3

獥s呩瑬攠


p慲慭整敲eempWy

䥬汥l慬a牧um敮瑅硣xp瑩on


4

獥s呩瑬攠


p慲慭整敲eno琠emp瑹⁘

g整呩瑬T⠩( 㴽 X


5

獥s䅵瑨Wr


p慲am整敲 汬

䥬汥l慬a牧um敮瑅硣xp瑩on


6

獥s䅵瑨Wr


p慲am整敲⁥mp瑹

䥬汥l慬a牧um敮瑅硣xp瑩on


7

獥s䅵瑨Wr


p慲am整敲 W 敭pWy⁘

g整䅵瑨W爨⤠‽㴠X


8

獥s䥳In


p慲am整敲 汬

䥬汥l慬a牧um敮瑅硣xp瑩on


9

獥s䥳In


p慲am整敲⁥mp瑹

䥬汥l慬a牧um敮瑅硣xp瑩on




獥s䥳In


p慲am整敲 W⁥mp瑹

†† ††† ††††
value “12345678”

䥬汥l慬a牧um敮瑅硣xp瑩on




獥s䥳In


p慲am整敲 W⁥mp瑹

†† ††† ††††
value “123456789”

getIsbn() == “123456789”




獥s䥳In


p慲am整敲 W⁥mp瑹

†† ††† ††††
value “isbn: 123
-
4567
-
89”

getIsbn() == “isbn: 123
-
4567
-
89”




獥sCopy䥤


p慲慭整敲⁶慬u攠0

䥬汥l慬a牧um敮瑅硣xp瑩on




獥sCopy䥤


p慲慭整敲⁶慬u攠1

g整䍯py䥤⠩(=㴠1


nov
-
2011 Peter Levinsky

15

setCopyId


parameter value 4

getCopyId() == 4


16

setCopyId


parameter value 15

getCopyId() == 15


17

setCopyId


parameter value 16

IllegalArgumentException


18

setCopyId


parameter value
-
1

IllegalArgumentException


19

Constructor(“title”,”author”,”123456789”,4)

getTitle() == “title”

getAuthor() ==

“author”

getIsbn() == “123456789”

getCopyId() == 4


20

Constructor(null,”author”,”123456789”,4)

IllegalArgumentException


21

Constructor(”title”,””,”123456789”,4)

IllegalArgumentException


22

Constructor(”title”,”author”,”wrong”,4)

IllegalArgumentException


23

Constructor(“title”,”author”,”123456789”,0)

IllegalArgumentException


24

Tostring

Constructor(“title”,”author”,”123456789”,4)

toString() ==

“title=title author=author
isbn= 123456789 copyId=4”







To automate these test cases we can use JUnit test

see the Netbeans tutorial
http://netbeans.org/kb/docs/java/junit
-
intro.html