Block 3 Unit 11 Flashcards

1
Q

Given n classes A1, …, An, each of which uses the method foo implemented in m classes C1, …, Cm, all of which are subclasses of parent class C, calculate how many tests will be required using the following approaches:
a.the safe approach (Figure 5)
b.the minimal approach (Figure 6)
c.the balanced approach (Figure 7) to integration testing.
For this case which would be the most appropriate choice?

A

(a) m × n
(b) max(m, n)
(c) m + n − 1
m + n − 1 is not much bigger than max(m, n), so the balanced approach might as well be used in preference to the minimal approach. However m × n is generally much bigger than both m + n − 1 and max(m, n). So if the safe approach were used in preference to the balanced approach the testing load could increase dramatically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Are there any situations in which system testing should be carried out by the implementers of a system?

A

Probably the only situation where this is appropriate is when the project team is small. In small teams, one person might play the part of requirements engineer, designer, implementer, tester and maintenance engineer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do you think is the relationship between system testing and acceptance testing?

A

In general, the same tests will be carried out during acceptance testing and system testing. System testing is an in-house activity and a customer need never know how system testing went – any bugs can be dealt with before the customer sees them. Acceptance testing, on the other hand, is conducted with much more at stake – the customer can accept or reject a system based on its performance at acceptance testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why should regression testing be necessary even after the customer has accepted the product after acceptance testing

A

Acceptance testing is the process of showing that the software meets the customer’s requirements, not that there aren’t bugs in the code. In fact, given that a system is put into use, bugs that require fixing are almost certain to be found after acceptance testing. In addition, the system will be maintained, with functionality added and changed, leading to a requirement for regression testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Use the following phrases, which describe four kinds of testing, to fill the gaps in the following three sentences.
usability testing, requirements testing, security testing, regression testing
TDD and DbC are valuable but not comprehensive tools for _________________.
TDD has ________________ built into it.
DbC and TDD cannot substitute for thorough _______________ or _________.

A

TDD and DbC are valuable but not comprehensive tools for requirements testing.
TDD has regression testing built into it.
DbC and TDD cannot substitute for thorough usability testing or security testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of unit, integration, system and acceptance testing are parts of validation and which are parts of verification?

A

Unit and integration testing concentrate on whether parts of the system perform according to their specifications, answering the verification question (have we built the system correctly?). System and thus acceptance testing focus on showing that the customer’s requirements have been met, answering the validation question (have we built the right system?). Note however that there are no hard and fast distinctions. Unit testing can be used to demonstrate that a component satisfies a customer’s requirements – thus viewed as validation – and system testing can be used to demonstrate that a system operates according to specification – viewed as verification.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give an example where black-box testing will test something that white-box testing would miss, and one where white-box testing will test something that black-box testing would miss.

A

Because black-box testing takes its test cases from the specification, it is likely to pick up the following sorts of errors that white-box testing would miss (this is not an exhaustive list):
operations required by the specification but not provided for by the implementation
errors between the interfaces of two classes
errors in the transformations between internal states of a class, if these affect input/output behaviour
performance errors, in which system performance is found to be wanting
system initialisation and termination errors.
On the other hand, in looking inside the implementation, white-box testing will pick up the following sorts of errors that black-box testing would miss:
the sequences of method calls in the body of a method that fail to perform the correct function
boolean conditions in if statements, while loops, etc. incorrectly expressed
loops that terminate incorrectly
relationships between methods and attributes of classes that are incorrect.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A weather-recording system records wind-speed data, rainfall data and barometric pressure, and sends summary data into a computer network. If the wind-speed data is represented as an integer between 0 and 110, the rainfall data is represented as a floating point number between 0.0 and 150.0 (significant to 1 decimal place) and barometric pressure is represented as an integer between 800 and 1200, what is the input data space?

A

The input data space is the set of triples of values taken from the sets {0, 1, …, 110}, {0.0, 0.1, …, 150.0} and {800, 801, …, 1200}.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Should the cyclomatic-complexity metric be used to measure the complexity of an object-oriented software system?

A

Because the cyclomatic-complexity metric is based on decision points, which are present only in methods, it is ‘blind’ to the class-structuring mechanisms that are available in object-oriented system descriptions. As much of the complexity of an object-oriented system is held in the class structure, applying the cyclomatic-complexity metric to a whole system would not therefore be appropriate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Compare the complexities of the following two pieces of code using the LOC and cyclomatic-complexity metrics. What conclusions can you draw about the relative complexity of the code?
Code A Code B
int i = 1; int j = 0;
while (i

A

Each piece of code has seven lines. The complexity according to the LOC metric is therefore the same. Code A has cyclomatic complexity 3 whereas code B has cyclomatic complexity 1, which suggests that code A is the more complex of the two. This supports an intuitive view that the structure of code A appears more complex than that of code B.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Look again at the definition of the DIT metric. When calculating the metric do you think that classes from the Java API should be included? Do you think that API classes should be counted in Chidamber and Kemerer’s other metrics?

A

Chidamber and Kemerer’s metrics measure complexity, and API classes add to complexity. Hence they should be counted in all metric calculations. For this reason, the Java documentation will be very useful when calculating these metrics.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The WMPC metric measures the complexity of a class in terms of the sum of the cyclomatic complexities of its methods.

a. Consider a class with ten methods, whose WMPC value is 40. How confident can you be that this class is not too complex?
b. If the WMPC value of a class with ten methods is over 100, how certain can you be that this class is too complex?

A

For individual methods, a cyclomatic complexity of 10 or more should be regarded as a hint that the method is too complex. In the case of classes, a little more thought is needed.

a. For a class with ten methods, a value for the WMPC metric of 40 would typically suggest acceptably low class complexity. However although nearly all of the ten methods might be acceptably simple, one or two might be unacceptably complex.
b. By contrast, a complexity of greater than 10 × 10 = 100 is a fair indication that the behaviour of the class is too complex.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The following piece of code is a method for equality testing from the java.util.Arrays class. Calculate the cyclomatic complexity for this method by filling in the right-hand column of Table 5, cumulatively.

Table 5 Code from java.util.Arrays
Line number	Code	Cyclomatic complexity
1	public static boolean equals(long[] a, long[] a2) {	
2	if (a==a2)	
3	return true;	
4	if (a==null || a2==null)	
5	return false;	
6	int length = a.length;	
7	if (a2.length != length)	
8	return false;	
9	for (int i=0; i
A
Table 6 Calculation of cyclomatic complexity
Line number	Cyclomatic complexity
1	1 (starts at one)
2	2 (if statement)
4	3, 4 (if statement, ||)
7	5 (if statement)
9	6 (for loop)
10	7 (if statement)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly