Negative test cases | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Negative test cases

A hammer can push a nail into a wall but cannot cut a tree, for that you need an axe ! This example certifies that negative test cases are as important as the positive ones ?🤔 Yes or no ?

1st Aug 2019, 1:46 AM
Sanjay Kamath
Sanjay Kamath - avatar
3 Answers
+ 6
So what is the negative test case here? A test to verify that a hammer can't cut a tree?
1st Aug 2019, 7:13 AM
Sonic
Sonic - avatar
+ 5
Well I guess that would depend on the size of the tree and your willingness to pound a hammer at it, because I’m sure a hammer will knock a tree down if you’re patient or strong enough to keep at it. I think that best represents using the right tool for the job. (You wouldnt use a thousand lines of if statements to check each element in a large list when a loop can do it in 5 lines would you?) You install a pad-lock to secure your belongings, but it turns out it never came with a code. Well your stuff is safe, but now you can’t access them either. (probably should’ve made sure it came with a code)
1st Aug 2019, 2:38 AM
Jake
Jake - avatar
+ 2
So what is the negative test case here? A test to verify that a hammer can't cut a tree? 🤔🤔🤔 Yes !!
1st Aug 2019, 11:02 AM
Sanjay Kamath
Sanjay Kamath - avatar