nus-cs2103-AY2324S1 / forum

10 stars 0 forks source link

Clarification on test coverage #562

Closed GlendaChong closed 10 months ago

GlendaChong commented 10 months ago

Hi everyone and Prof @damithc, for a similar question like this, but for testing 100% branch and condition coverage respectively, how will one actually go about doing it?

For for loops, there is a condition of i < s.length(), do we consider that as a branch/condition? If yes, will that mean a varying number of times of test, and hence cannot be determined?

image
damithc commented 10 months ago

For for loops, there is a condition of i < s.length(), do we consider that as a branch/condition?

@GlendaChong Yes, it is a branch, with one condition. To achive branch or condition coverage, it must be true at least once, and false at least once.

GlendaChong commented 10 months ago

Okay, thank you!