Vous êtes sur la page 1sur 7

PRINCIPLES OF SOFTWARE DEVELOPMENT

2012-2013

Exercise

Universidad Carlos III de Madrid

Tenth Guided Exercise 2012/2013

STRUCTURAL TESTING: CONTROL FLOW ANALYSIS

Exercise 10

Universidad Carlos III de Madrid. Escuela Politcnica Superior

Javier Garca Guzmn

S T R U C T U R A L

T E S T I N G :

C O N T R O L

F L O W

A N A L Y S I S

Objectives
using the technique of the analysis of internal flow.

Chapter

This guided exercise has as main objective to enable the learning of the structural testing

Statement of the Work


This guided exercise consists of programming and executing several unit tests for verifying that the Hand and PlayerHandParser classes are correct. The PlayerHandParser source code is provided with this statement of the work. It contains a public method: ParsePlayerHand. The interface defined for this method is: public Card[] ParsePlayerHand (ArrayList<String> PlayerHand) throws PokerException The input parameter is an arraylist of five strings string with an expected format that is: <cardvalue>,<suit>; The possible values of cardvalue are: {Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King} The possible values of suit are: {CLUBS, DIAMONDS, HEARTS, SPADES} The function provided by this method consists of creating the internal representation of the cards hold by the player. The structure of this representation is an array of cards. The card class is defined in the source code provided with this statement of the work. If the input string has an incorrect format, then isFullHouse method has to throw the PokerException. The interface defined for this method is: public boolean isFullHouse() throws PokerException
Guided Exercise 10 Statement of the Work
2 2 0 1 2 / 2 0 1 3

S T R U C T U R A L

T E S T I N G :

C O N T R O L

F L O W

A N A L Y S I S

The function provided by this method consists of determining if the hand the player holds a full house. Full House is a popular hand combination of a three of a kind with a pair. The output provided by isFullHouse method is a Boolean value corresponding to the result of the evaluation of the players hand against the full house characteristics. The student has to design and implement the cases to test properly

PlayerHandParser.ParsePlayerHand and Hand.isFullHouse methods applying the Control Flow Analysis.

Step 1: Definition of the flow graph of the method to be tested


The student has to define a flow graph for representing the internal control flow of the method to be tested.

Step 2: Identify the required test cases for considering statement coverage
It consists of generating the needed test cases to execute, once at least, each sequence of instructions.

Step 3: Identify the required test cases for considering branch coverage
It consists of generating the enough test cases in order to assure that each branch included in the source code has at least one positive evaluation (TRUE) and one negative evaluation (FALSE). Generally, the execution of tests for decisions coverage fulfills the restrictions stated for sequence coverage tests.

Step 4: Identify the required test cases for considering loop coverage
It consists of generating the enough test cases in order to evaluate properly all the loops included in the methods to be tested

Guided Exercise 10 Statement of the Work

2 0 1 2 / 2 0 1 3

S T R U C T U R A L

T E S T I N G :

C O N T R O L

F L O W

A N A L Y S I S

Step 5: Implement the test cases selected


The student has to develop the test cases identified in the previous steps using the JUnit framework and programming interface.

Step 6: Execute the test cases developed


The student has to execute the test cases developed using the JUnit user interface in order to verify the correct performance of PlayerHandParser.ParsePlayerHand and Hand.isFullHouse methods. The test registries generated by JUnit has to be saved in a separate file.

Guided Exercise 10 Statement of the Work

2 0 1 2 / 2 0 1 3

S T R U C T U R A L

T E S T I N G :

C O N T R O L

F L O W

A N A L Y S I S

Rules and procedures Rules and Procedures


This exercise will be completed individually.

Chapter

When youve completed the exercise, submit your solution package (a zip file) including: Source code to be tested. Source code for testing automation. The report generated by JUnit notifying the results of the test cases implemented.

Each student must submit the exercise solution to the corresponding folder created at Aula Global 2. The deadline to submit the exercise 10 solution is 08/05/2013 before 16:00. Following the subject evaluation rules, if a student does not send the exercise solution before the fixed deadline, the student will be evaluated with 0 points.

Guided Exercise 10 Statement of the Work

2 0 1 2 / 2 0 1 3

S T R U C T U R A L

T E S T I N G :

C O N T R O L

F L O W

A N A L Y S I S

Evaluation Criteria
There is a class for automating the test cases proposed for the ParsePlayerHand method (testParsePlayerHand) of PlayerHandParser class and for the test cases considered for the isFullHouse method (testIsFullHouse) of Hand class. The testParsePlayerHand class contains all the test cases that can be identified using the Control Flow Analysis technique. The testIsFullHouse class contains all the test cases that can be identified using the Control Flow Analysis technique. The test reports are provided by the student. The execution of the automated tests cases runs appropriately finding the expected errors.

Suggestions
Each student should keep a copy of the solution delivered until the end of the subject.

Guided Exercise 10 Statement of the Work

2 0 1 2 / 2 0 1 3

Vous aimerez peut-être aussi