CS FundamentalsModerateTCS NQT · Infosys
What is the minimum number of tests that gives 100% statement coverage of this fragment?
What is the minimum number of tests that gives 100% statement coverage of this fragment?
if a > 0:
if b > 0:
X()
else:
Y()
else:
Z()- A. 1
- B. 3
- C. 2
- D. 4
Correct answer: B. 3
X, Y and Z lie on mutually exclusive paths, so every one needs its own test: 3. The same 3 tests also give branch coverage, matching V(G) = 2 + 1 = 3.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A function contains if x > 5: A() followed later by if x < 3: B(), and x is not changed between them. How many entry-to-exit paths are…
- A tester has no reliable way to know the correct output for a complex scientific simulation, so she checks that doubling every input mass…
- In which situation does a suite with 100% decision (branch) coverage still NOT achieve 100% multiple-condition coverage?
- You append line L1 to a tracked file f.txt, run git add f.txt, and then append line L2. Which statement about the three diff commands is…
- main has commits A-B-C-D. feature was created at B and has commits E-F. How many commits do git log main..feature and git log…
- On main (…-C-D) you run git merge feature, where feature has E-F-G, creating merge commit M. Its first parent is D and its second is G…