Black-box and White-box Testing : Week 2 Quiz answers

Partition Testing

1) In Partition Testing, the idea is to fragment the ___ space into subsets, in such a way that some of these are ___ in terms of values that expose faults.

a) output; dense
b) input; dense
c) code; sparse
d) test; sparse

ANS - b) input; dense

2) The partitions that are constructed are always domain ______.

a) dependent b) independent

ANS - a) dependent

3) In practice, every program fault can lead to a failure-dense partition.

a) False b) True

ANS - a) False

4) In Quasi-partitioning, overlapping partitions are allowed to exist.

a) True b) False

ANS - a) True


Combinatorial Testing


1) In Combinatorial Testing, the goal is to identify distinct tests and combine them to create new ones.

a) False b) True

ANS - a) False

2) In Category-partition testing, we create categories of values for each _____ defined in the system

a) test 
b) input 
c) output 
d) interaction

ANS - b) input

3) Why are constraints important in Category-partition testing?

a) They alleviate the problem of creating duplicate tests.
b) They are used to identify representative values.
c) They provide a way to filter out meaningless combinations of attributes.
d) Monitoring interactions between attributes is easier when using constraints.

ANS - c) They provide a way to filter out meaningless combinations of attributes.

4) Property constraints are used to include specific combinations of attribute values.

a) False b) True

ANS - a) False

5) How does N-way Combinatorial testing improve over the traditional method?

a) Only a subset of the representative values are required to generate good test cases
b) We can rule out impossible combinations
c) We can identify interactions that only require a part of the given attributes in the original specification

ANS
c) We can identify interactions that only require a part of the given attributes in the original specification

Requirements Coverage

1) A good principle when creating tests is to focus on checking failure cases only.

a) False b) True 

ANS - a) False

2) We can consider cases of buffer overflow as success cases.

a) False b) True 

ANS - a) False

3) What kind of cases do we mostly exercise from using tests generated in Behavior-Driven Development?

a) failure cases
b) success cases

ANS - b) success cases

4) Consider the case where we use Partition testing to generate tests for a given set of requirements. To achieve requirements coverage, which of the following must be true?

a) Each partition needs to cover success and/or failure cases.
b) Attribute value combinations must exercise boundary cases.
c) Dense partitions must cover success cases.

ANS - a) Each partition needs to cover success and/or failure cases.

5) Consider the case where we use Combinatorial testing to generate tests for a given set of requirements. To achieve requirements coverage, which of the following must be true?

a) Tests need to cover every combination of attribute values.
b) Attribute value combinations need to cover both success and failure cases.

ANS - b) Attribute value combinations need to cover both success and failure cases. 


Code Coverage Metrics: Statement Coverage

1) Which of the following descriptions about statement coverage is not true?

a) It usually requires the least number of test cases among other structural coverage criteria.
b) It requires a test suite to execute each statement in the program at least once.
c) It is very ineffective and not used in practice.
d) It is the most basic structural coverage criterion.

ANS - c) It is very ineffective and not used in practice.

2) What are the kinds of faults that statement coverage cannot reveal?

a) A division-by-zero bug in an arithmetic statement.
b) A fault that can be triggered when an if-condition is not taken.
c) A fault that can be triggered when a loop is not executed.

ANS
b) A fault that can be triggered when an if-condition is not taken.
c) A fault that can be triggered when a loop is not executed.

Code Coverage Metrics: Branch Coverage

1) Branch coverage subsumes statement coverage.

a) False b) True

ANS - b) True

2) Which of the following is not true about branch coverage?

a) Branch coverage requires each branch in the program to be followed on both sides.
b) Branch coverage ensures that each outcome of an IF is tested.
c) Branch coverage provides better fault-finding efficacy than statement coverage.
d) A test suite that satisfies statement coverage also satisfies branch coverage.

ANS - d) A test suite that satisfies statement coverage also satisfies branch coverage.


3) What kind of faults can branch coverage not reveal?

a) A fault that can be triggered when a loop is not executed.
b) A  division-by-zero bug in an arithmetic statement.
c) A fault that can be triggered when an if-condition is not taken

ANS - a) A fault that can be triggered when a loop is not executed.


Code Coverage Metrics: Decision Coverage

1) Which is the correct description of decision coverage?

a) Decision coverage requires every decision in the program to be exercised.
b) Decision coverage requires every boolean decision in the program, including assignments to the boolean variables, to produce both outcomes - true and false.
c) Decision coverage requires a test suite to exercise every decision in the branches to take both true and false

ANS
b) Decision coverage requires every boolean decision in the program, including assignments to the boolean variables, to produce both outcomes - true and false.

2) In the following code, what line(s) include a decision?

double calc_ratio(int a, int b, bool c) {
  double ratio = 0;
  bool a_non_negative = a >= 0;
  bool safe = a < 5 && b != 0;
  if (a_non_negative && safe && !c) {
    ratio = a / b;
  }
  return ratio;
}

a) (line 3) a>= 0
b) (line 5) a_non_negative && safe && !c
c) (line 4) a < 5 && b != 0
d) (line 6) ratio = a / b

ANS -
a) (line 3) a>= 0 
b) (line 5) a_non_negative && safe && !c
c) (line 4) a < 5 && b != 0

3) Which of the following is not true about decision coverage?

a) Decision coverage subsumes branch coverage.
b) Decision coverage requires every decision in the program, including assignments of Boolean variables, to be exercised both sides.
c) Decision coverage requires individual condition in every decision to take both values.
d) Decision coverage subsumes statement coverage.

ANS
c) Decision coverage requires individual condition in every decision to take both values.

Code Coverage Metrics: MC/DC

1) Which of the following is the most accurate description of MC/DC?

a) It requires a test suite to exercise both true and false outcomes of each condition.
b) It requires a test suite to exercise both true and false outcomes of each condition and that each condition independently affects the decision outcome.
c) It requires a test suite to exercise all the combinatorial outcomes of conditions in each decision

ANS
b) It requires a test suite to exercise both true and false outcomes of each condition and that each condition independently affects the decision outcome.

2) What is MC/DC good at?

a) Finding arithmetic and relational errors.
b) Catching errors in complex Boolean expressions.
c) Ensuring all control flow branches are tested.
d) Ensuring all program statements get tested.

ANS
b) Catching errors in complex Boolean expressions.
c) Ensuring all control flow branches are tested.
d) Ensuring all program statements get tested.

3) Which of the following is not true about MC/DC?

a) MC/DC demonstrates independent effect of all conditions on their containing decision.
b) MC/DC is more rigorous than statement, branch, and decision coverage.
c) MC/DC is more effective when the program is structured with as many if statements as possible.

ANS - c) MC/DC is more effective when the program is structured with as many if statements as possible.

4) For the decision given below, which of the following is a set of test cases that satisfies MC/DC? Select all that apply. Reminder: there can be more than one test suite which provides MC/DC coverage for any given set of code statements.

bool decision = (A && B) || C;

a) { (T, T, T), (F, F, F) }
b) { (T, T, F), (F, T, F), (T, F, F), (T, F, T) }
c) { (T, T, F), (F, T, F), (T, F, F), (F, T, T) }
d) { (T, T, F), (F, T, F), (T, F, F), (F, F, T) }
e) { (T, T, F), (T, F, T), (F, T, T), (F, F, F) }

ANS
b) { (T, T, F), (F, T, F), (T, F, F), (T, F, T) }
c) { (T, T, F), (F, T, F), (T, F, F), (F, T, T) }

5) What is the minimum number of test cases we need to satisfy MC/DC in the following decision?

if (!c && (a || b)) {
  return 1;
} else {
  return 2;
}

ANS - 





Comments

Popular Posts