Note of testing and test

advertisement

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 System testing is done 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 check 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

3

4

5

6

7

8

9

10

Test case

#

1

2

The title must be not null and not empty.

The Author must be not null and not empty.

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)

11

12

13

14

Description of test case

Default constructor setTitle – parameter null setTitle – parameter empty setTitle – parameter not empty X setAuthor – parameter null setAuthor – parameter empty setAuthor – parameter not empty X setIsbn – parameter null setIsbn – parameter empty setIsbn – parameter not empty

value “12345678” setIsbn – parameter not empty

value “123456789” setIsbn – parameter not empty

value “isbn: 123-4567-89” setCopyId – parameter value 0 setCopyId – parameter value 1

Expected value

Object created

IllegalArgumentException

IllegalArgumentException getTitle() == X

IllegalArgumentException

IllegalArgumentException getAuthor() == X

IllegalArgumentException

IllegalArgumentException

IllegalArgumentException getIsbn() == “123456789” getIsbn() == “isbn: 123-4567-

89”

IllegalArgumentException getCopyId() == 1

Passed succesfully nov-2011 Peter Levinsky

15

16

17

18

19

20

21

22

23

24 setCopyId – parameter value 4 setCopyId – parameter value 15 getCopyId() == 4 getCopyId() == 15 setCopyId – parameter value 16 setCopyId – parameter value -1

IllegalArgumentException

IllegalArgumentException

Constructor(“title”,”author”,”123456789”,4) getTitle() == “title” getAuthor() == “author” getIsbn() == “123456789” getCopyId() == 4

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

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

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

IllegalArgumentException

IllegalArgumentException

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

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

nov-2011 Peter Levinsky

Download