Software Engineering for Students A Programming Approach
Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach
Exercises 279 In black box (or functional) testing, sample data based on the specification is used. This is termed equivalence partitioning. In white box (or structural) testing, the internal structure of the software is used to select test data. This means that every path through the program is tested. Unit testing tests each component in isolation. Drivers and stubs are used to substitute for missing components. Integration testing tests components as they are brought together. 19.1 Consider a program that has 16 if-then statements in it. Then there are 216 • Exercises possible paths through it. If each test takes 50 microseconds and each action takes 50 microseconds (a gross underestimate), how much computer time is needed to test all program paths? 19.2 Devise black box and white box test data to test the following program. The program specification is: The program inputs a series of integers from the keyboard using a text field. The program finds the largest of the numbers. The numbers are terminated when a button labeled Start Again is pressed. Try not to look at the text of the program, given below, until you have completed the design of the black box data. The program involves the following class: class Biggest { private int largest; } public Biggest() { largest = 0; } public void nextNumber(int n) { if (n > largest) largest = n; } public void display(TextField textField) { textField.setText("largest so far is" + largest); } public void startAgain() { largest = 0; }
280 Chapter 19 ■ Testing 19.3 Devise black box and white box test data to test the following program. The program specification is: The program is to determine insurance premiums for a holiday, based upon the age and gender (male or female) of the client. For a female of age >= 18 and = 31 pays $3.50. A male of age >= 18 and = 36 pays $5.50. People aged 50 or more pay half premium. Any other ages or genders are an error, which is signaled as a premium of zero. The Java code for this program is: public float calcPremium(float age, String gender) { float premium; } if (gender.equals("female")) if ((age >= 18) && (age = 31) premium = 3.50f; else premium = 0.0f; else if (gender.equals("male")) if ((age >= 18) && (age = 36) premium = 5.5f; else premium = 0.0f; else premium = 0.0f; if (age >= 50) premium = premium * 0.5f; return premium; 19.4 Suggest features for software tools that could assist in using each of the following techniques: ■ black box testing ■ white box testing. 19.5 Substantial testing of a system uncovers not a single error. What conclusions would you draw?
- Page 251 and 252: 228 Chapter 16 ■ Programming in t
- Page 253 and 254: 230 Chapter 16 ■ Programming in t
- Page 255 and 256: 232 Chapter 16 ■ Programming in t
- Page 257 and 258: 234 Chapter 16 ■ Programming in t
- Page 259 and 260: 236 Chapter 16 ■ Programming in t
- Page 261 and 262: 238 Chapter 17 ■ Software robustn
- Page 263 and 264: 240 Chapter 17 ■ Software robustn
- Page 265 and 266: 242 Chapter 17 ■ Software robustn
- Page 267 and 268: 244 Chapter 17 ■ Software robustn
- Page 269 and 270: 246 Chapter 17 ■ Software robustn
- Page 271 and 272: 248 Chapter 17 ■ Software robustn
- Page 273 and 274: 250 Chapter 17 ■ Software robustn
- Page 275 and 276: 252 Chapter 17 ■ Software robustn
- Page 277 and 278: 254 Chapter 17 ■ Software robustn
- Page 279 and 280: 256 Chapter 17 ■ Software robustn
- Page 281 and 282: 258 Chapter 17 ■ Software robustn
- Page 283 and 284: 260 Chapter 18 ■ Scripting GNU/Li
- Page 285 and 286: 262 Chapter 18 ■ Scripting In sum
- Page 288: PART D VERIFICATION
- Page 291 and 292: 268 Chapter 19 ■ Testing We begin
- Page 293 and 294: 270 Chapter 19 ■ Testing within a
- Page 295 and 296: 272 Chapter 19 ■ Testing Test num
- Page 297 and 298: 274 Chapter 19 ■ Testing if (a >=
- Page 299 and 300: 276 Chapter 19 ■ Testing 3. apply
- Page 301: 278 Chapter 19 ■ Testing made con
- Page 305 and 306: 282 Chapter 19 ■ Testing 19.2 The
- Page 307 and 308: 284 Chapter 20 ■ Groups The term
- Page 309 and 310: 286 Chapter 20 ■ Groups Of course
- Page 311 and 312: 288 Chapter 20 ■ Groups • Exerc
- Page 314 and 315: CHAPTER 21 This chapter explains: 2
- Page 316 and 317: Stage Input Output 21.3 Feedback be
- Page 318 and 319: Summary The essence and the strengt
- Page 320 and 321: CHAPTER 22 This chapter: 22.1 ● I
- Page 322 and 323: 22.2 The spiral model 299 to try to
- Page 324 and 325: 22.4 ● Discussion Exercises 301 A
- Page 326 and 327: CHAPTER 23 Prototyping This chapter
- Page 328 and 329: Therefore, in summary: ■ the prod
- Page 330 and 331: 23.5 Evolutionary prototyping 307 U
- Page 332 and 333: Reuse components 23.6 Rapid prototy
- Page 334 and 335: Pitfalls For users, the problems of
- Page 336 and 337: Answers to self-test questions 313
- Page 338 and 339: 24.2 ● Big-bang implementation 24
- Page 340 and 341: Tested component Figure 24.1 Top-do
- Page 342 and 343: 24.7 ● Use case driven implementa
- Page 344 and 345: ■ middle-out ■ use case based.
- Page 346 and 347: SELF-TEST QUESTION 25.1 What is the
- Page 348 and 349: sharing of software or their own re
- Page 350 and 351: Summary 327 Inappropriate patches,
Exercises 279<br />
In black box (or functional) testing, sample data based on the specification is used.<br />
This is termed equivalence partitioning.<br />
In white box (or structural) testing, the internal structure of the software is used<br />
to select test data. This means that every path through the program is tested.<br />
Unit testing tests each component in isolation. Drivers and stubs are used to substitute<br />
<strong>for</strong> missing components. Integration testing tests components as they are<br />
brought together.<br />
19.1 Consider a program that has 16 if-then statements in it. Then there are 216 •<br />
Exercises<br />
possible<br />
paths through it. If each test takes 50 microseconds and each action takes 50<br />
microseconds (a gross underestimate), how much computer time is needed to test all<br />
program paths?<br />
19.2 Devise black box and white box test data to test the following program. The program<br />
specification is:<br />
The program inputs a series of integers from the keyboard using a text field. The<br />
program finds the largest of the numbers. The numbers are terminated when a button<br />
labeled Start Again is pressed.<br />
Try not to look at the text of the program, given below, until you have completed the<br />
design of the black box data.<br />
The program involves the following class:<br />
class Biggest {<br />
private int largest;<br />
}<br />
public Biggest() {<br />
largest = 0;<br />
}<br />
public void nextNumber(int n) {<br />
if (n > largest)<br />
largest = n;<br />
}<br />
public void display(TextField textField) {<br />
textField.setText("largest so far is" + largest);<br />
}<br />
public void startAgain() {<br />
largest = 0;<br />
}