-1

If there is eqaution as C=A/B and requirements is C>=0 then can you write testcase on this scenario?

Oggy
  • 1
  • Welcome to stackoverflow.com. Please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). Also please [take the tour](http://stackoverflow.com/tour) and [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask). Lastly please read [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude Nov 27 '19 at 08:26
  • And what have you tried yourself? Any thoughts of your own about its feasibility or how to do it? Perhaps even a [mcve] of your own attempt? – Some programmer dude Nov 27 '19 at 08:28

1 Answers1

0

Given the requirement that C>=0 you should consider boundary value testing to ensure that this has been implemented correctly. The most common way for a bug to be introduced given this requirement is for the developer to use > instead of >=. By considering the boundaries we will get the following tests:

  • A = 0, B = 2 expected answer C = 0.
  • A = -1, B = 2 expected answer error, C is negative.

The interesting part about this question is that the requirement is on the output not the inputs. Typically you would constrain the inputs and therefore have requirements on the values for A and B not on C.

There is a whole topic on what is expected when B is zero as well, but that is drifting a long way from the original question.

James Wilson
  • 1,541
  • 7
  • 20