Why is my Edge test failing?

Modified on Tue, 28 Mar, 2023 at 4:40 PM

Do you understand the error?

Edge tests fail if our code is not checking for the weak points on the inputs.

Where is the error occurring?

Error is the logic of the code, where we are not checking for the edge inputs. Can we look at the constraints of the problem and check if we are covering all the possible inputs?

Why do you think you are seeing this error? What might be causing it?:

Can we unlock the failing test case and run it, this will help us understand what is the input, expected output and actual output for the failing test case. We can dry run on this if needed to find the issue with the logic in our code.

How to Debug this? To debug this issue, I would recommend the following steps:

To avoid this, it is recommended that you write a few test cases even before you start writing the code. This will save your debugging time and help you write better logic.

We can write a few test cases and check how those input values are handled by the code. For example let’s say we are asked to find the middle character of give string, the possible edge test cases we would test for are:

  1. What if the input string is empty?

  2. What if the input string only had one char?

  3. What if the input string is of even length?

  4. What if the input string is of odd length?

Now once we find where the logic is failing, we can update our code so our code passes these test cases.

Resource: How to come up with edge cases



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article