Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9....

13
Problem solving #7- TESTING True or False 1. With thorough testing it is possible to remove all defects from a program prior to delivery to the customer. 2. Verifications is checking that we are building the right system. 3. Code inspections are better than testing for finding defects. 4. When testing object-oriented software, it is important to test each class operation separately as part of the unit testing process. 5. Scenario-based testing concentrates on actor and software interaction. 6. Program testing can reveal the absence of errors. 7. Inspections cannot check non-functional characteristics such as performance, usability, etc. 8. A successful test of defect testing is a test that makes the system performs incorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress testing can be used to verify the mentioned non-functional requirement. 10. When an interface error, such as the parameters being displayed are in the wrong order occurs, this error is known as “interface misunderstanding”. 11. Validation is demonstrating conformance to a specification whereas verification is checking that a system meets the customer's needs. 12. A program need not be completely free of defects before delivery if remaining defects are minor defects that do not cause system corruption and which are transient i.e. which can be cleared when new data is input. 13. Software verification tries to answer the question “Are we building the product right?” 14. The debugging process is intended to establish the existence of defects in software while verification and validation tries to locate and corrects these defects. 15. Program inspections are effective in finding program errors. The aim of an inspection is to locate faults. 16. The main objective of system testing is to establish that the system meets its functional and non-functional requirements.

Transcript of Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9....

Page 1: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

Problem solving #7- TESTING

True or False

1. With thorough testing it is possible to remove all defects from a program prior to

delivery to the customer.

2. Verifications is checking that we are building the right system.

3. Code inspections are better than testing for finding defects.

4. When testing object-oriented software, it is important to test each class operation

separately as part of the unit testing process.

5. Scenario-based testing concentrates on actor and software interaction.

6. Program testing can reveal the absence of errors.

7. Inspections cannot check non-functional characteristics such as performance,

usability, etc.

8. A successful test of defect testing is a test that makes the system performs

incorrectly and so exposes a defect in the system.

9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

testing can be used to verify the mentioned non-functional requirement.

10. When an interface error, such as the parameters being displayed are in the wrong

order occurs, this error is known as “interface misunderstanding”.

11. Validation is demonstrating conformance to a specification whereas verification is

checking that a system meets the customer's needs.

12. A program need not be completely free of defects before delivery if remaining

defects are minor defects that do not cause system corruption and which are transient

i.e. which can be cleared when new data is input.

13. Software verification tries to answer the question “Are we building the product

right?”

14. The debugging process is intended to establish the existence of defects in software

while verification and validation tries to locate and corrects these defects.

15. Program inspections are effective in finding program errors. The aim of an

inspection is to locate faults.

16. The main objective of system testing is to establish that the system meets its

functional and non-functional requirements.

Page 2: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

17. White box (or structural) testing strategy is most suitable in component testing.

18. Black box testing strategy is most suitable in integration testing.

19. A successful test is one where the system performs correctly. This statement refers

to defect testing.

20. Performance and stress testing must be conducted during component testing.

21. Developing test cases for the system prototype is one of the requirements

validation techniques. (F)

22. The main objective of system testing is to establish that the system meets its

functional and non-functional requirements.

23. White box testing strategy is most suitable in component testing, while black box testing strategy is most suitable in integration testing.

24. Release testing is usually performed using black-box testing, whereby testers do not necessarily have knowledge of the system implementation.

25. Release testing is conducted during system development in order to discover bugs and defects in the system.

26. Equivalence partitioning is a strategy that can be used to reduce the number of test cases by dividing the input domain of a program into classes.

27. Validation is where the software should do what the user really requires.

28. Verification and validation in software engineering means that the software should be completely free of defects.

29. Confidence that the software is fit for purpose means that the software must be good enough for satisfying its purpose.

30. Software testing and code inspection are the examples of verification technique.

31. Software inspection technique requires execution of a system, hence, it may be used after software implementation.

32. Verification and Validation are optional. One can replace another.

33. Software Testing is a dynamic Validation.

34. State Diagram is useful for Software Inspection.

35. Release Testing is usually referred as Black Box Testing.

36. A Beta Version is a version used for Testing at the Developer’s site.

37. Basis Path Testing is a technique for Black Box Testing.

Page 3: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

Guided questions

Question 1 (10 marks)

a. In verification and validation (V&V), inspection and testing are two methods

applied to find out defects in the software. Explain at least THREE differences

between inspection and testing. (4.5M)

b. Explain the difference between testing and debugging. (2M)

c. What is the structure of a software test plan? (3.5M)

Question 2 (10 marks)

a. What is basis path testing strategy? (1M)

b. Given a flow graph with N nodes and P paths, what is the cyclomatic complexity

of the flow graph. What is the relationship between cyclomatic complexity and

basis path of a flow graph? (2M)

c. Draw the flow graph for the following program: (3M)

#include <iostream>

int main()

{

int choice, months;

double charges;

do

{

displayMenu();

cin >> choice;

if (choice >= 1 && choice <= 3)

{

cout << "For how many months? ";

cin >> months;

switch (choice)

{

case 1: charges = months * 40.0;

break;

case 2: charges = months * 20.0;

break;

case 3: charges = months * 30.0;

}

cout << "The total charges are $" << charges

<< endl;

}

Page 4: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

else if (choice != 4)

{

cout << "Invalid choice. Please try

again.\n";

}

} while (choice != 4);

return 0;

}

d. List all basis path of the flow graph that you generate from part (c). (2M)

e. Provide test data for each of the basis path that you identify in (d). (2M)

Question 3 (20 marks)

a. Consider a module, called “ElecBill” which is part of Tenaga National Berhad

(TNB) billing application. The ElecBill module is to compute bill payment of

electrical consumption for different users. In order to promote saving, TNB

charge a lower rate to users with lower consumption as shown in Table 1.

User Type

[Jenis Pengguna]

First Rate

[Kadar Pertama]

Second Rate

[Kadar Kedua]

Household 0.10 for first 500 unit 0.25 for the following

units

Office 0.25 for first 1000 unit 0.50 for the following

units

Factory 0.50 for first 1500 unit 0.75 for the following

units

Table 1: Rate

i. Write test-cases for testing the functionality of this module by using equivalence

partitioning technique. Name each class and identify the input of each class in

the test-cases. (6M)

Page 5: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

ii. Write test-cases for testing the functionality of this module by using boundary-

value analysis technique. Name each class and identify the input of each class

in the test-cases. (6M)

iii. Discuss if the two techniques can be supported using automated static

analysis. (2M)

b. Discuss the TWO differences of the above testing techniques with basic path

testing technique. Suggest at which phase the techniques should be planned

in verification and validation planning. (6M)

Question 4 [10 marks]

a. What is the difference between software inspection and software testing. List

two (2) advantage of software inspection over software testing. (4M)

b. Study the following C++ code, and then answer the question:

if ((num >= 20) && (num <= 100))

{cout<<”valid number”; }

else

{cout<<”invalid number”; }

i. By using the Boundary Value Analysis (BVA), identify the test cases

required to perform a complete coverage? (3M)

ii. By using the Equivalence Class Partitioning, identify how many input

classes are required to test the part marked on C++ code shown. Name

each class identified. (3M)

Page 6: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

Question 5 [20 marks]

a. “Testing can only show the presence of errors in a program. It cannot

demonstrate that there are no remaining faults”

Based on the statement above, explain why testing can only detect the

presence of errors, not their absence.

b. Based on Figure 2, answer the following questions:

Figure 2

i. Draw a Flow Graph for the procedure in Figure 1. (5M)

ii. Calculate the cyclomatic complexity of Figure 1 procedure. (1M)

iii. Identify and list down all independent paths based on your answer in (i)

(4M)

#include <iostream>

Using Namespace std;

double total,hours;

int main()

{

cout << "Charges for the first 3 hours = RM2.00" << endl;

cout << "Additional charges for the next hours = RM1.50" << endl;

cout << "Maximum charges for any 24 hours = RM20.00" << endl;

cout << "\nPlease insert your hours = ";

cin >> hours;

if ((hours <=3) && (hours > 0))

cout << "\nYour total fee is RM2.00" << endl;

else

if ((hours>3) && (hours<=15))

{

total = 2.00+((hours-3)*1.50);

cout << "\nYour total fee is RM" << total << endl;

}

else

if (hours>15)

{

cout << "\nYour total fee is RM20.00" << endl;

}

else

cout << "\nError! Please insert a valid number of hours" <<

endl;

system(“PAUSE”);

return 0;

}

Page 7: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

iv. Design a test case to force execution down each independent path. Use a

table when designing your test cases. (5M)

QUESTION 6

Suppose a buy-online-ticket application for a theme park is selling tickets at prices as

shown in Table 1. The application will ask the buyer for his age, and the type of

tickets he wants to buy. The application will then identify the required price for the

ticket.

Table 1: Ticket Rate

Ticket Type Age (years) Price (RM)

Daily 3-11 110

12-59 140

60-75 110

Annual Pass 10-60 275

Based on the description above, answer the following questions:

Rules: Please answer question 3(a) and 3(c) using format in Table 2.

Table 2: Equivalence class partitioning

Equivalence Class

Ticket type

Age

Expected output

(a)Using the Equivalence Class Partitioning technique, derive one test case for

each of the classes that you have identified for Daily ticket only. [5 marks]

(b)Using the Boundary Value Analysis (BVA) technique, identify the boundary

values required to perform a complete coverage for Annual Pass? [3 marks]

(c)Based on your answer in (b), provide any TWO (2) appropriate test cases. [2

marks]

Page 8: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

QUESTION 7

(a) Software testing is very important in software development process. Give TWO

(2) main goals of software testing process? [2 marks]

(b) Define the following terms: [2 marks]

(a)Alpha Testing

(b)Beta Testing

(c) Integration testing and release testing are two distinct phases in system testing.

Give ONE(1) difference between integration testing and release testing. [2 marks]

(d) Draw a flow graph for the following code in Figure 1 and calculate the Cyclomatic

Complexity. [4 marks]

#include <iostream>

int main()

{

int choice, months;

double charges;

do

{

displayMenu();

cin >> choice;

if (choice >= 1 && choice <= 3)

{

cout << "For how many months? ";

cin >> months;

switch (choice)

{

case 1: charges = months * 40.0;

brea

k;

case 2: charges = months * 20.0;

brea

k;

case 3: charges = months * 30.0;

}

cout << "The total charges are $" << charges << endl;

}

else if (choice != 4)

{

cout << "Invalid choice. Please try again.\n";

}

} while (choice != 4);

return 0;

}

Page 9: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

QUESTION 8

a. Referring to your case study, Wilderness Weather Station System, describe TWO (2) types of Development testing that can be executed to the system [4 marks]

b. Briefly describe what Basic Path Testing is. [1 mark]

c. What is the cyclomatic complexity of the Flow Graph in Figure 4 and how the result from the cyclomatic complexity can be used in Basic Path Testing [2 marks]

d. With respect to Figure 4, identify THREE (3) independent paths for Basic Path Testing. [3 marks]

Figure 4

Page 10: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

QUESTION 9

There are 3 categories of people parking at a shopping complex, which are regular

customer, member customer and employee. The parking charges are as shown in

Table 3.

a) Draw a Flow Graph diagram for the codes given in Figure 7. [5

marks]

b) Give the cyclomatic complexity of the flow graph in question a. List only FOUR

(4) independent path based on the flow graph. [5 marks]

c) List all valid and invalid equivalence classes based on Table 1 (there should be 1

invalid and 4 valid equivalence classes identified) [5 marks]

a. Design test cases using the equivalence class you have identified in (c) by

filling in the data in Table 2. [5 marks]

Path status hour Expected Output

Invalid INPUT. Please key-in the hour

again

Free parking

Total parking charge is RM1.50

Total parking charge is RM1.50

Total parking charge is RM60.00

Page 11: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

QUESTION 10

a) List FOUR (4) steps to define Basis Path Testing.

[4 marks]

b) What is an independent path? Why do you think independence path are

important to be indentified in Basis Path Testing? (new added question)

[4 marks]

c) State TWO (2) formula to calculate Cyclomatic Complexity.

[2 marks]

QUESTION 11

Suppose a buy-online-ticket application for a theme park is selling tickets at prices

as shown in Table 1. The application will ask the buyer for his age, and it will then

identify the required price for the ticket.

Table 1

Ticket Type Price

1-Day Child Ticket

(Age: 3-11)

RM 80

1-Day Adult Ticket

(Age:12-59)

RM 140

1-Day Senior Ticket

(Age: 60-75)

RM 110

a) List all valid and invalid equivalence classes based on Table 1 (there should be 5

equivalence classes identified) [5 marks]

b) Design test case using the equivalence class you have identified in (a) by filling

in the data in Table 2.

[5 marks]

Page 12: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

Table 2

Equivalence Class # Age Expected Output

1

2

3

4

5

Study the codes in Figure 2, and then answer questions c) and d):

...

int driver_age, total_risk=1;

char car_type;

cout << “Enter your age AND car type: ”;

cin >> driver_age >> car_type;

if (driver_age>=20 && driver_age<=25)

total_risk = total_risk + 10;

if (car_type == 'X')

{

if (driver_age<25)

total_risk = total_risk + 8;

else

total_risk = total_risk + 6;

}

else if (car_type == 'C')

total_risk = total_risk + 4;

cout << “Your total risk is ” << total_risk;

...

Figure 2

Page 13: Problem solving #7- TESTING True or Falseincorrectly and so exposes a defect in the system. 9. “The booking ticketing system can handle up to 35 booking simultaneously”. Stress

c) Draw a flow graph diagram for the codes given in Figure 2.

[5 marks]

d) What is the cyclomatic complexity of the flow graph in question c)? List only

THREE (3) independent path based on the flow graph.

[5 marks]